| | 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 | | /// Provides information about the creation of the Element. |
| | 11 | | /// See https://spdx.github.io/spdx-spec/v3.0.1/model/Core/Classes/CreationInfo/ |
| | 12 | | /// </summary> |
| | 13 | | public class CreationInfo : BaseModelClass, ILiteDomainCompliantElement |
| | 14 | | { |
| | 15 | | [JsonPropertyName("comment")] |
| | 16 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 14 | 17 | | public string? Comment { get; set; } |
| | 18 | |
|
| | 19 | | [JsonPropertyName("created")] |
| | 20 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 261 | 21 | | public required DateTimeOffset Created { get; set; } |
| | 22 | |
|
| | 23 | | [JsonPropertyName("createdBy")] |
| | 24 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 543 | 25 | | public IList<Agent> CreatedBy { get; } = new List<Agent>(); |
| | 26 | |
|
| | 27 | | [JsonPropertyName("createdUsing")] |
| | 28 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 307 | 29 | | public IList<Tool> CreatedUsing { get; } = new List<Tool>(); |
| | 30 | |
|
| | 31 | | [JsonPropertyName("specVersion")] |
| | 32 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 315 | 33 | | public string SpecVersion { get; set; } = "3.0.1"; |
| | 34 | |
|
| | 35 | | // protected internal no-parm constructor required for deserialization |
| | 36 | | // ReSharper disable once UnusedMember.Global |
| 58 | 37 | | protected internal CreationInfo() |
| | 38 | | { |
| 58 | 39 | | } |
| | 40 | |
|
| | 41 | | [SetsRequiredMembers] |
| 1 | 42 | | public CreationInfo(Catalog catalog) : base(catalog) |
| | 43 | | { |
| 1 | 44 | | Created = DateTimeOffset.UtcNow; |
| 1 | 45 | | } |
| | 46 | |
|
| | 47 | | [SetsRequiredMembers] |
| 231 | 48 | | public CreationInfo(Catalog catalog, DateTimeOffset created) : base(catalog) |
| | 49 | | { |
| 231 | 50 | | Created = created; |
| 231 | 51 | | } |
| | 52 | |
|
| | 53 | | public void Accept(ILiteDomainComplianceVisitor visitor) |
| | 54 | | { |
| 3 | 55 | | visitor.Visit(this); |
| 3 | 56 | | } |
| | 57 | |
|
| | 58 | | public override void Validate() |
| | 59 | | { |
| 3 | 60 | | base.Validate(); |
| 2 | 61 | | ValidateRequiredProperty(nameof(CreatedBy)); |
| 2 | 62 | | } |
| | 63 | | } |