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