This repository was archived by the owner on Mar 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPackageType.cs
More file actions
46 lines (39 loc) · 1.81 KB
/
PackageType.cs
File metadata and controls
46 lines (39 loc) · 1.81 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
using System;
using System.Collections.Generic;
namespace ProjectFileTools.NuGetSearch.Contracts
{
public class PackageType : IEquatable<PackageType>
{
public static IReadOnlyList<PackageType> DefaultList { get; } = new[] { KnownPackageType.Dependency };
public PackageType(string id, string version = null)
{
Name = id ?? throw new ArgumentNullException(nameof(id));
Version = version;
}
public string Name { get; }
public string Version { get; }
public override bool Equals(object obj) => Equals(obj as PackageType);
public bool Equals(PackageType other) => other is PackageType
&& string.Equals(Name, other.Name, StringComparison.Ordinal)
&& string.Equals(Version, other.Version, StringComparison.Ordinal);
public override int GetHashCode()
{
int hashCode = -612338121;
hashCode = hashCode * -1521134295 + StringComparer.Ordinal.GetHashCode(Name);
if (Version is not null) {
hashCode = hashCode * -1521134295 + StringComparer.Ordinal.GetHashCode(Version);
}
return hashCode;
}
}
public class KnownPackageType
{
public static PackageType Legacy { get; } = new PackageType("Legacy");
public static PackageType DotnetCliTool { get; } = new PackageType("DotnetCliTool");
public static PackageType Dependency { get; } = new PackageType("Dependency");
public static PackageType DotnetTool { get; } = new PackageType("DotnetTool");
public static PackageType SymbolsPackage { get; } = new PackageType("SymbolsPackage");
public static PackageType DotnetPlatform { get; } = new PackageType("DotnetPlatform");
public static PackageType MSBuildSdk { get; } = new PackageType("MSBuildSdk");
}
}