| | | 1 | | using System.Diagnostics.CodeAnalysis; |
| | | 2 | | using System.Text.Json.Serialization; |
| | | 3 | | using Spdx3.Exceptions; |
| | | 4 | | using Spdx3.Model.Core.Classes; |
| | | 5 | | using Spdx3.Serialization; |
| | | 6 | | using Spdx3.Utility; |
| | | 7 | | |
| | | 8 | | namespace Spdx3.Model.Software.Classes; |
| | | 9 | | |
| | | 10 | | public class Snippet : SoftwareArtifact |
| | | 11 | | { |
| | | 12 | | [JsonPropertyName("software_byteRange")] |
| | | 13 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| | 5 | 14 | | public PositiveIntegerRange? ByteRange { get; set; } |
| | | 15 | | |
| | | 16 | | [JsonPropertyName("software_lineRange")] |
| | | 17 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| | 9 | 18 | | public PositiveIntegerRange? LineRange { get; set; } |
| | | 19 | | |
| | | 20 | | [JsonPropertyName("software_snippetFromFile")] |
| | | 21 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| | 15 | 22 | | public File SnippetFromFile { get; set; } |
| | | 23 | | #pragma warning disable CS8618, CS9264 |
| | | 24 | | // protected internal no-parm constructor required for deserialization |
| | | 25 | | // ReSharper disable once UnusedMember.Global |
| | 2 | 26 | | protected internal Snippet() |
| | | 27 | | { |
| | 2 | 28 | | } |
| | | 29 | | #pragma warning restore CS8618, CS9264 |
| | | 30 | | |
| | | 31 | | [SetsRequiredMembers] |
| | 3 | 32 | | public Snippet(Catalog catalog, CreationInfo creationInfo, File snippetFromFile) : base(catalog, creationInfo) |
| | | 33 | | { |
| | 3 | 34 | | SnippetFromFile = snippetFromFile; |
| | 3 | 35 | | } |
| | | 36 | | |
| | | 37 | | public override void Validate() |
| | | 38 | | { |
| | 4 | 39 | | base.Validate(); |
| | | 40 | | |
| | 3 | 41 | | if (SnippetFromFile == null) |
| | | 42 | | { |
| | 1 | 43 | | throw new Spdx3ValidationException(this, nameof(SnippetFromFile), "Cannot be null, empty, or whitespace."); |
| | | 44 | | } |
| | 2 | 45 | | } |
| | | 46 | | } |