-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathCppSdkComponent.cs
More file actions
55 lines (47 loc) · 1.65 KB
/
Copy pathCppSdkComponent.cs
File metadata and controls
55 lines (47 loc) · 1.65 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
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using PackageUrl;
/// <summary>
/// Represents a C++ SDK component.
/// </summary>
public class CppSdkComponent : TypedComponent
{
/// <summary>
/// Initializes a new instance of the <see cref="CppSdkComponent"/> class.
/// </summary>
public CppSdkComponent()
{
/* Reserved for deserialization */
}
/// <summary>
/// Initializes a new instance of the <see cref="CppSdkComponent"/> class.
/// </summary>
/// <param name="name">The name of the component.</param>
/// <param name="version">The version of the component.</param>
public CppSdkComponent(string name, string version)
{
this.Name = this.ValidateRequiredInput(name, nameof(this.Name), nameof(ComponentType.CppSdk));
this.Version = this.ValidateRequiredInput(version, nameof(this.Version), nameof(ComponentType.CppSdk));
}
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("version")]
public string Version { get; set; }
[JsonIgnore]
public override ComponentType Type => ComponentType.CppSdk;
[JsonPropertyName("packageUrl")]
public override PackageURL PackageUrl
{
get
{
var qualifiers = new SortedDictionary<string, string>
{
{ "type", "cppsdk" },
};
return new PackageURL("generic", null, this.Name, this.Version, qualifiers, null);
}
}
protected override string ComputeBaseId() => $"{this.Name} {this.Version} - {this.Type}";
}