9 internal readonly
struct ModuleVersionComponent : IComparable<ModuleVersionComponent>
12 public static bool operator ==(ModuleVersionComponent x, ModuleVersionComponent y) => x.Equals(y);
14 public static bool operator !=(ModuleVersionComponent x, ModuleVersionComponent y) => x.Equals(y) ==
false;
16 public static bool operator <(ModuleVersionComponent x, ModuleVersionComponent y) => Compare(x, y) < 0;
18 public static bool operator >(ModuleVersionComponent x, ModuleVersionComponent y) => Compare(x, y) > 0;
20 public static bool operator <=(ModuleVersionComponent x, ModuleVersionComponent y) => Compare(x, y) <= 0;
22 public static bool operator >=(ModuleVersionComponent x, ModuleVersionComponent y) => Compare(x, y) >= 0;
24 public static int Compare(ModuleVersionComponent x, ModuleVersionComponent y) => x.CompareTo(y);
26 readonly
int _integer;
27 readonly
string? _string;
33 public ModuleVersionComponent(
int value)
43 public ModuleVersionComponent(
string value)
52 public readonly
bool IsInteger => _string is
null;
57 public readonly
int AsInteger() => _string is
null ? _integer :
throw new InvalidOperationException();
62 public readonly
string AsString() => _string ?? _integer.ToString();
65 public readonly
int CompareTo(ModuleVersionComponent other)
67 if (IsInteger && other.IsInteger)
68 return AsInteger().CompareTo(other.AsInteger());
70 return AsString().CompareTo(other.AsString());
74 public readonly
override bool Equals(
object? obj)
76 return obj is ModuleVersionComponent other && Equals(other);
84 public readonly
bool Equals(ModuleVersionComponent other)
86 return CompareTo(other) == 0;
90 public readonly
override int GetHashCode()
93 return AsInteger().GetHashCode();
95 return AsString().GetHashCode();