forked from microsoft/component-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCargoComponent.cs
More file actions
42 lines (31 loc) · 1.35 KB
/
Copy pathCargoComponent.cs
File metadata and controls
42 lines (31 loc) · 1.35 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
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using Newtonsoft.Json;
using PackageUrl;
public class CargoComponent : TypedComponent
{
private CargoComponent()
{
// reserved for deserialization
}
public CargoComponent(string name, string version, string author = null, string license = null, string source = null)
{
this.Name = this.ValidateRequiredInput(name, nameof(this.Name), nameof(ComponentType.Cargo));
this.Version = this.ValidateRequiredInput(version, nameof(this.Version), nameof(ComponentType.Cargo));
this.Author = author;
this.License = license;
this.Source = source;
}
public string Name { get; set; }
public string Version { get; set; }
#nullable enable
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string? Author { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string? License { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string? Source { get; set; }
#nullable disable
public override ComponentType Type => ComponentType.Cargo;
public override PackageURL PackageUrl => new PackageURL("cargo", null, this.Name, this.Version, null, null);
protected override string ComputeId() => $"{this.Name} {this.Version} - {this.Type}";
}