| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Exceptions; |
| | 4 | | using Spdx3.Model.Core.Classes; |
| | 5 | | using Spdx3.Model.Software.Enums; |
| | 6 | | using Spdx3.Serialization; |
| | 7 | | using Spdx3.Utility; |
| | 8 | |
|
| | 9 | | namespace Spdx3.Model.Software.Classes; |
| | 10 | |
|
| | 11 | | public class File : SoftwareArtifact |
| | 12 | | { |
| | 13 | | private string _name; |
| | 14 | |
|
| | 15 | | [JsonPropertyName("software_contentType")] |
| | 16 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 3 | 17 | | public string? ContentType { get; set; } |
| | 18 | |
|
| | 19 | | [JsonPropertyName("software_fileKind")] |
| | 20 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 3 | 21 | | public FileKindType? FileKind { get; set; } |
| | 22 | |
|
| | 23 | | [JsonPropertyName("name")] |
| | 24 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| | 25 | | public new string Name |
| | 26 | | { |
| 8 | 27 | | get => _name; |
| | 28 | | set |
| | 29 | | { |
| 3 | 30 | | if (string.IsNullOrWhiteSpace(value)) |
| | 31 | | { |
| 1 | 32 | | throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace."); |
| | 33 | | } |
| | 34 | |
|
| 2 | 35 | | _name = value; |
| 2 | 36 | | } |
| | 37 | | } |
| | 38 | |
|
| | 39 | | // protected internal no-parm constructor required for deserialization |
| | 40 | | #pragma warning disable CS8618, CS9264 |
| | 41 | | // ReSharper disable once UnusedMember.Global |
| 4 | 42 | | protected internal File() |
| | 43 | | { |
| 4 | 44 | | } |
| | 45 | | #pragma warning restore CS8618, CS9264 |
| | 46 | |
|
| | 47 | | [SetsRequiredMembers] |
| 6 | 48 | | public File(Catalog catalog, CreationInfo creationInfo, string name) : base(catalog, creationInfo) |
| | 49 | | { |
| 6 | 50 | | if (string.IsNullOrWhiteSpace(name)) |
| | 51 | | { |
| 1 | 52 | | throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace."); |
| | 53 | | } |
| | 54 | |
|
| 5 | 55 | | _name = name; |
| 5 | 56 | | } |
| | 57 | |
|
| | 58 | |
|
| | 59 | | public override void Validate() |
| | 60 | | { |
| 4 | 61 | | base.Validate(); |
| | 62 | |
|
| 2 | 63 | | if (string.IsNullOrWhiteSpace(Name)) |
| | 64 | | { |
| 0 | 65 | | throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace."); |
| | 66 | | } |
| 2 | 67 | | } |
| | 68 | | } |