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.Common; |
| 12 | using BaSyx.Models.Export.Converter; |
| 13 | using Newtonsoft.Json; |
| 14 | using System.Collections.Generic; |
| 15 | using System.Xml.Serialization; |
| 16 | |
| 17 | namespace BaSyx.Models.Export |
| 18 | { |
| 19 | public class SubmodelElementCollection_V1_0 : SubmodelElementType_V1_0, IModelType |
| 20 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 21 | [JsonProperty("allowDuplicates")] |
| 22 | [XmlElement("allowDuplicates")] |
| 23 | public bool AllowDuplicates { get; set; } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 24 | |
| 25 | [JsonProperty("ordered")] |
| 26 | [XmlElement("ordered")] |
| 27 | public bool Ordered { get; set; } |
| 28 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 29 | [JsonProperty("value"), JsonConverter(typeof(JsonSubmodelElementConverter_V1_0))] |
| 30 | [XmlArray("value")] |
| 31 | [XmlArrayItem("submodelElement")] |
| 32 | public List<EnvironmentSubmodelElement_V1_0> Value { get; set; } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 33 | |
| 34 | [JsonProperty("modelType")] |
| 35 | [XmlIgnore] |
| 36 | public override ModelType ModelType => ModelType.SubmodelElementCollection; |
| 37 | |
| 38 | public SubmodelElementCollection_V1_0() { } |
| 39 | public SubmodelElementCollection_V1_0(SubmodelElementType_V1_0 submodelElementType) : base(submodelElementType) { } |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame^] | 40 | |
| 41 | public bool ShouldSerializeValue() |
| 42 | { |
| 43 | if (Value == null || Value.Count == 0) |
| 44 | return false; |
| 45 | else |
| 46 | return true; |
| 47 | } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 48 | } |
| 49 | } |