/// <summary> /// Compares <see langword="this"/> to the <see cref="Version"/> in <paramref name="other"/> using <see cref="Version.CompareTo(Version)"/>. /// </summary> /// <remarks> /// The storage method of <see langword="this"/> must be <see cref="StoredAs.SemVer"/>, else an <see cref="InvalidOperationException"/> will /// be thrown. /// </remarks> /// <param name="other">the <see cref="Version"/> to compare to</param> /// <returns>less than 0 if <paramref name="other"/> is considered bigger than <see langword="this"/>, 0 if equal, and greater than zero if smaller</returns> /// <seealso cref="CompareTo(AlmostVersion)"/> public int CompareTo(Version other) { if (StorageMode != StoredAs.SemVer) throw new InvalidOperationException("Cannot compare a SemVer version with an AlmostVersion stored as a string!"); return SemverValue.CompareTo(other); }
/// <summary> /// Compares <see langword="this"/> to the <see cref="AlmostVersion"/> in <paramref name="other"/> using <see cref="Version.CompareTo(Version)"/> /// or <see cref="string.CompareTo(string)"/>, depending on the current store. /// </summary> /// <remarks> /// The storage methods of the two objects must be the same, or this will throw an <see cref="InvalidOperationException"/>. /// </remarks> /// <param name="other">the <see cref="AlmostVersion"/> to compare to</param> /// <returns>less than 0 if <paramref name="other"/> is considered bigger than <see langword="this"/>, 0 if equal, and greater than zero if smaller</returns> /// <seealso cref="CompareTo(Version)"/> public int CompareTo(AlmostVersion other) { if (other == null) return -1; if (StorageMode != other.StorageMode) throw new InvalidOperationException("Cannot compare AlmostVersions with different stores!"); if (StorageMode == StoredAs.SemVer) return SemverValue.CompareTo(other.SemverValue); else return StringValue.CompareTo(other.StringValue); }