| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Serialization; |
| | 4 | | using Spdx3.Utility; |
| | 5 | |
|
| | 6 | | // ReSharper disable UnusedMember.Global |
| | 7 | |
|
| | 8 | | namespace Spdx3.Model.Core.Classes; |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// A key with an associated value. |
| | 12 | | /// See https://spdx.github.io/spdx-spec/v3.0.1/model/Core/Classes/DictionaryEntry/ |
| | 13 | | /// </summary> |
| | 14 | | public class DictionaryEntry : BaseModelClass |
| | 15 | | { |
| | 16 | | [JsonPropertyName("key")] |
| | 17 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 8 | 18 | | public required string Key { get; set; } |
| | 19 | |
|
| | 20 | | [JsonPropertyName("value")] |
| | 21 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 7 | 22 | | public string? Value { get; set; } |
| | 23 | |
|
| | 24 | | // protected internal no-parm constructor required for deserialization |
| 1 | 25 | | protected internal DictionaryEntry() |
| | 26 | | { |
| 1 | 27 | | } |
| | 28 | |
|
| | 29 | | [SetsRequiredMembers] |
| 5 | 30 | | public DictionaryEntry(Catalog catalog, string key) : base(catalog) |
| | 31 | | { |
| 5 | 32 | | Key = key; |
| 5 | 33 | | } |
| | 34 | |
|
| | 35 | | [SetsRequiredMembers] |
| 4 | 36 | | public DictionaryEntry(Catalog catalog, string key, string? value) : this(catalog, key) |
| | 37 | | { |
| 4 | 38 | | Value = value; |
| 4 | 39 | | } |
| | 40 | |
|
| | 41 | | public override void Validate() |
| | 42 | | { |
| 2 | 43 | | base.Validate(); |
| 1 | 44 | | ValidateRequiredProperty(nameof(Key)); |
| 1 | 45 | | } |
| | 46 | | } |