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 BaSyx.Models.Export.Converter; |
| 14 | using Newtonsoft.Json; |
| 15 | using System.Collections.Generic; |
| 16 | using System.Xml.Serialization; |
| 17 | |
| 18 | namespace BaSyx.Models.Export |
| 19 | { |
| 20 | public class EnvironmentSubmodel_V2_0 : EnvironmentIdentifiable_V2_0, IModelType |
| 21 | { |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 22 | [JsonProperty("kind")] |
| 23 | [XmlElement("kind")] |
| 24 | public ModelingKind Kind { get; set; } |
| 25 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 26 | [JsonProperty("semanticId")] |
| 27 | [XmlElement("semanticId")] |
| 28 | public EnvironmentReference_V2_0 SemanticId { get; set; } |
| 29 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 30 | [JsonProperty("constraints")] |
| 31 | [XmlArray("qualifier")] |
| 32 | [XmlArrayItem("qualifier")] |
| 33 | public List<EnvironmentQualifier_V2_0> Qualifier { get; set; } |
| 34 | |
| 35 | [JsonProperty("submodelElements"), JsonConverter(typeof(JsonSubmodelElementConverter_V2_0))] |
| 36 | [XmlArray("submodelElements")] |
| 37 | [XmlArrayItem("submodelElement")] |
| 38 | public List<EnvironmentSubmodelElement_V2_0> SubmodelElements { get; set; } |
| 39 | |
| 40 | [JsonProperty("modelType")] |
| 41 | [XmlIgnore] |
| 42 | public ModelType ModelType => ModelType.Submodel; |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 43 | |
| 44 | public bool ShouldSerializeSemanticId() |
| 45 | { |
| 46 | if (SemanticId == null || SemanticId.Keys?.Count == 0) |
| 47 | return false; |
| 48 | else |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | public bool ShouldSerializeQualifier() |
| 53 | { |
| 54 | if (Qualifier == null || Qualifier.Count == 0) |
| 55 | return false; |
| 56 | else |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | public bool ShouldSerializeSubmodelElements() |
| 61 | { |
| 62 | if (SubmodelElements == null || SubmodelElements.Count == 0) |
| 63 | return false; |
| 64 | else |
| 65 | return true; |
| 66 | } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 67 | } |
| 68 | } |