-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
ManifestId.cs
40 lines (33 loc) · 1.03 KB
/
ManifestId.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.NET.Sdk.WorkloadManifestReader
{
public struct ManifestId : IEquatable<ManifestId>, IComparable<ManifestId>
{
private string _id;
public ManifestId(string id)
{
_id = id?.ToLowerInvariant() ?? throw new ArgumentNullException(nameof(id));
}
public bool Equals(ManifestId other)
{
return ToString() == other.ToString();
}
public int CompareTo(ManifestId other)
{
return string.Compare(ToString(), other.ToString(), StringComparison.Ordinal);
}
public override bool Equals(object? obj)
{
return obj is ManifestId id && Equals(id);
}
public override int GetHashCode()
{
return _id.GetHashCode();
}
public override string ToString()
{
return _id ?? "";
}
}
}