/// 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)"/>
publicintCompareTo(AlmostVersionother)
{
if(otherisnull)return1;
}
else
{
StringValue=str;
StorageMode=StoredAs.String;
returntrue;
}
}
/// <summary>
/// The value of the <see cref="AlmostVersion"/> if it was stored as a <see cref="string"/>.
/// </summary>
/// <value>the stored value as a <see cref="string"/>, or <see langword="null"/> if not stored as a string.</value>
publicstring?StringValue{get;privateset;}
/// <summary>
/// The value of the <see cref="AlmostVersion"/> if it was stored as a <see cref="Version"/>.
/// </summary>
/// <value>the stored value as a <see cref="Version"/>, or <see langword="null"/> if not stored as a version.</value>
publicVersion?SemverValue{get;privateset;}
/// <summary>
/// The way the value is stored, whether it be as a <see cref="Version"/> or a <see cref="string"/>.
/// </summary>
/// <value>the storage mode used to store this value</value>
publicStoredAsStorageMode{get;privateset;}
/// <summary>
/// Gets a string representation of the current version. If the value is stored as a string, this returns it. If it is
/// stored as a <see cref="Version"/>, it is equivalent to calling <see cref="Version.ToString()"/>.
/// </summary>
/// <returns>a string representation of the current version</returns>
/// 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>
/// 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)"/>
publicintCompareTo(Versionother)
{
if(StorageMode!=StoredAs.SemVer)
thrownewInvalidOperationException("Cannot compare a SemVer version with an AlmostVersion stored as a string!");
/// Compares <see langword="this"/> to the <see cref="SVersion"/> 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="SVersion"/> 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)"/>
[Obsolete("Use the Hive.Versioning.Version overload instead.")]
/// 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)"/>
publicintCompareTo(Versionother)
{
if(StorageMode!=StoredAs.SemVer)
thrownewInvalidOperationException("Cannot compare a SemVer version with an AlmostVersion stored as a string!");
returnSemverValue!.CompareTo(other);
}
/// <summary>
/// Compares <see langword="this"/> to the <see cref="SVersion"/> 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="SVersion"/> 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)"/>
[Obsolete("Use the Hive.Versioning.Version overload instead.")]
/// Performs a strict equality check between <see langword="this"/> and <paramref name="obj"/>.
/// </summary>
/// <remarks>
/// This may return <see langword="false"/> where <see cref="operator ==(AlmostVersion, AlmostVersion)"/> returns <see langword="true"/>
/// </remarks>
/// <param name="obj">the object to compare to</param>
/// <returns><see langword="true"/> if they are equal, <see langword="false"/> otherwise</returns>
/// <seealso cref="object.Equals(object)"/>
publicoverrideboolEquals(objectobj)
{
returnobjisAlmostVersionversion&&
SemverValue==version.SemverValue&&
StringValue==version.StringValue&&
StorageMode==version.StorageMode;
}
/// <summary>
/// Compares two versions, only taking into account the numeric part of the version if they are stored as <see cref="Version"/>s,
/// or strict equality if they are stored as <see cref="string"/>s.
/// </summary>
/// <remarks>
/// This is a looser equality than <see cref="Equals(object)"/>, meaning that this may return <see langword="true"/> where <see cref="Equals(object)"/>
/// does not.
/// </remarks>
/// <param name="l">the first value to compare</param>
/// <param name="r">the second value to compare</param>
/// <returns><see langword="true"/> if they are mostly equal, <see langword="false"/> otherwise</returns>
/// Compares two versions, only taking into account the numeric part of the version if they are stored as <see cref="Version"/>s,
/// or strict equality if they are stored as <see cref="string"/>s.
/// </summary>
/// <remarks>
/// This is a looser equality than <see cref="Equals(object)"/>, meaning that this may return <see langword="true"/> where <see cref="Equals(object)"/>
/// does not.
/// </remarks>
/// <param name="l">the first value to compare</param>
/// <param name="r">the second value to compare</param>
/// <returns><see langword="true"/> if they are mostly equal, <see langword="false"/> otherwise</returns>