forked from microsoft/component-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpdxComponent.cs
More file actions
56 lines (43 loc) · 2.08 KB
/
SpdxComponent.cs
File metadata and controls
56 lines (43 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System;
using System.Text.Json.Serialization;
public class SpdxComponent : TypedComponent
{
public SpdxComponent()
{
/* Reserved for deserialization */
}
public SpdxComponent(string spdxVersion, Uri documentNamespace, string name, string checksum, string rootElementId, string path)
{
this.SpdxVersion = this.ValidateRequiredInput(spdxVersion, nameof(this.SpdxVersion), nameof(ComponentType.Spdx));
this.DocumentNamespace = this.ValidateRequiredInput(documentNamespace, nameof(this.DocumentNamespace), nameof(ComponentType.Spdx));
this.Name = this.ValidateRequiredInput(name, nameof(this.Name), nameof(ComponentType.Spdx));
this.Checksum = this.ValidateRequiredInput(checksum, nameof(this.Checksum), nameof(ComponentType.Spdx));
this.RootElementId = this.ValidateRequiredInput(rootElementId, nameof(this.RootElementId), nameof(ComponentType.Spdx));
this.Path = this.ValidateRequiredInput(path, nameof(this.Path), nameof(ComponentType.Spdx));
}
[JsonIgnore]
public override ComponentType Type => ComponentType.Spdx;
[JsonPropertyName("rootElementId")]
public string RootElementId { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("spdxVersion")]
public string SpdxVersion { get; set; }
[JsonPropertyName("documentNamespace")]
public Uri DocumentNamespace { get; set; }
[JsonPropertyName("checksum")]
public string Checksum { get; set; }
[JsonPropertyName("path")]
public string Path { get; set; }
#nullable enable
[JsonPropertyName("creatorTool")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? CreatorTool { get; set; }
[JsonPropertyName("creatorOrganization")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? CreatorOrganization { get; set; }
#nullable disable
protected override string ComputeBaseId() => $"{this.Name}-{this.SpdxVersion}-{this.Checksum}";
}