| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Exceptions; |
| | 4 | | using Spdx3.Serialization; |
| | 5 | | using Spdx3.Utility; |
| | 6 | |
|
| | 7 | | namespace Spdx3.Model.Extension.Classes; |
| | 8 | |
|
| | 9 | | public class CdxPropertiesExtension : Extension |
| | 10 | | { |
| | 11 | | [JsonPropertyName("extension_cdxProperty")] |
| | 12 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 16 | 13 | | public IList<CdxPropertyEntry> CdxProperty { get; init; } = new List<CdxPropertyEntry>(); |
| | 14 | |
|
| | 15 | | // protected internal no-parm constructor required for deserialization |
| | 16 | | // ReSharper disable once UnusedMember.Global |
| 2 | 17 | | protected internal CdxPropertiesExtension() |
| | 18 | | { |
| 2 | 19 | | } |
| | 20 | |
|
| | 21 | | [SetsRequiredMembers] |
| 3 | 22 | | public CdxPropertiesExtension(Catalog catalog, IList<CdxPropertyEntry> cdxProperties) : base(catalog) |
| | 23 | | { |
| 3 | 24 | | if (cdxProperties.Count == 0) |
| | 25 | | { |
| 1 | 26 | | throw new Spdx3ValidationException(this, nameof(CdxProperty), "Collection cannot be empty."); |
| | 27 | | } |
| | 28 | |
|
| 2 | 29 | | CdxProperty = cdxProperties; |
| 2 | 30 | | } |
| | 31 | |
|
| | 32 | | public override void Validate() |
| | 33 | | { |
| 3 | 34 | | base.Validate(); |
| | 35 | |
|
| 2 | 36 | | if (CdxProperty.Count == 0) |
| | 37 | | { |
| 1 | 38 | | throw new Spdx3ValidationException(this, nameof(CdxProperty), "Collection cannot be empty."); |
| | 39 | | } |
| 1 | 40 | | } |
| | 41 | | } |