Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2020 Robert Bosch GmbH |
| 3 | * Author: Constantin Ziesche (constantin.ziesche@bosch.com) |
| 4 | * |
| 5 | * This program and the accompanying materials are made available under the |
| 6 | * terms of the Eclipse Public License 2.0 which is available at |
| 7 | * http://www.eclipse.org/legal/epl-2.0 |
| 8 | * |
| 9 | * SPDX-License-Identifier: EPL-2.0 |
| 10 | *******************************************************************************/ |
| 11 | using BaSyx.Models.Core.AssetAdministrationShell.Enums; |
| 12 | using BaSyx.Models.Core.Common; |
| 13 | using Newtonsoft.Json; |
| 14 | using System.Collections.Generic; |
| 15 | using System.Xml.Serialization; |
| 16 | |
| 17 | namespace BaSyx.Models.Export |
| 18 | { |
| 19 | [XmlType(TypeName = "submodelElement")] |
| 20 | public class EnvironmentSubmodelElement_V1_0 |
| 21 | { |
| 22 | [XmlElement(ElementName = "property", Type = typeof(Property_V1_0))] |
| 23 | [XmlElement(ElementName = "file", Type = typeof(File_V1_0))] |
| 24 | [XmlElement(ElementName = "blob", Type = typeof(Blob_V1_0))] |
| 25 | [XmlElement(ElementName = "event", Type = typeof(Event_V1_0))] |
| 26 | [XmlElement(ElementName = "referenceElement", Type = typeof(ReferenceElement_V1_0))] |
| 27 | [XmlElement(ElementName = "relationshipElement", Type = typeof(RelationshipElement_V1_0))] |
| 28 | [XmlElement(ElementName = "submodelElementCollection", Type = typeof(SubmodelElementCollection_V1_0))] |
| 29 | [XmlElement(ElementName = "operation", Type = typeof(Operation_V1_0))] |
| 30 | public SubmodelElementType_V1_0 submodelElement; |
| 31 | } |
| 32 | |
| 33 | public class SubmodelElementType_V1_0 : EnvironmentReferable_V1_0, IModelType |
| 34 | { |
| 35 | [JsonProperty("semanticId")] |
| 36 | [XmlElement("semanticId")] |
| 37 | public EnvironmentReference_V1_0 SemanticId { get; set; } |
| 38 | |
| 39 | [JsonProperty("kind")] |
| 40 | [XmlElement("kind")] |
| 41 | public ModelingKind Kind { get; set; } |
| 42 | |
| 43 | [JsonProperty("constraints")] |
| 44 | [XmlArray("qualifier")] |
| 45 | [XmlArrayItem("qualifier")] |
| 46 | public List<EnvironmentQualifier_V1_0> Qualifier { get; set; } = new List<EnvironmentQualifier_V1_0>(); |
| 47 | |
| 48 | [XmlIgnore] |
| 49 | public virtual ModelType ModelType { get; } |
| 50 | |
| 51 | public SubmodelElementType_V1_0() { } |
| 52 | public SubmodelElementType_V1_0(SubmodelElementType_V1_0 submodelElementType) |
| 53 | { |
| 54 | this.Category = submodelElementType.Category; |
| 55 | this.Description = submodelElementType.Description; |
| 56 | this.IdShort = submodelElementType.IdShort; |
| 57 | this.Kind = submodelElementType.Kind; |
| 58 | this.Parent = submodelElementType.Parent; |
| 59 | this.Qualifier = submodelElementType.Qualifier; |
| 60 | this.SemanticId = submodelElementType.SemanticId; |
| 61 | } |
| 62 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 63 | public bool ShouldSerializeQualifier() |
| 64 | { |
| 65 | if (Qualifier == null || Qualifier.Count == 0) |
| 66 | return false; |
| 67 | else |
| 68 | return true; |
| 69 | } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 70 | } |
| 71 | } |