namespace EdgeInstaller; public sealed partial class Version : IComparable { public int CompareTo(Version? other) { if (other is null) { return 1; } // full Equality is easy since everything should be the same. // OPTIM: Doing this here is techinally more effecient than baking it in to the later code // Bools and shit if (this.Major == other.Major && this.Minor == other.Minor && this.Build == other.Build && this.Patch == other.Patch && this.Subpatch == other.Subpatch) { return 0; } // Compare major version if (Major != other.Major) return Major.CompareTo(other.Major); // Compare minor version if (Minor != other.Minor) return Minor.CompareTo(other.Minor); // Compare build number if (Build != other.Build) return Build.CompareTo(other.Build); // Compare patch number if (Patch != other.Patch) return Patch.CompareTo(other.Patch); // Compare subpatch number return Subpatch.CompareTo(other.Subpatch); } public bool Equals(Version? other) { if (other is null) { return false; } return this.CompareTo(other) == 0; } public static bool operator >(Version v1, Version v2) { return v1.CompareTo(v2) > 0; } public static bool operator <(Version v1, Version v2) { return v1.CompareTo(v2) < 0; } public static bool operator >=(Version v1, Version v2) { return v1.CompareTo(v2) >= 0; } public static bool operator <=(Version v1, Version v2) { return v1.CompareTo(v2) <= 0; } }