/// <summary> /// Compares the given version info objects according to IComparable specs: /// http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx. /// </summary> /// <returns> /// 0 on equality, -1 if info1 is older than info2, +1 if it's newer. /// Every object is greater than null and both null means equal. /// </returns> /// <param name='info1'> /// Info1. /// </param> /// <param name='info2'> /// Info2. /// </param> public static int DefaultCompareTo(TrackedBundleVersionInfo info1, TrackedBundleVersionInfo info2) { if ((object)info1 == null || (object)info2 == null) { return(((object)info1 == null ? -1 : 0) + ((object)info2 == null ? 1 : 0)); } // if both versions are not contained in TrackedBundleVersion.history perform a string compare // otherwise the non-registered is treated as older if (info1.index < 0 && info2.index < 0) { return(System.String.Compare(info1.version, info2.version)); // NOTE: we rely on index only; if history is manipulated manually this will lead to problems; // Provide a customised version and set it to static member compareTo } else if (info1.index > info2.index) { return(1); } else if (info1.index < info2.index) { return(-1); } else { return(0); } }
public bool Before(TrackedBundleVersionInfo info2) { return(compareTo(this, info2) < 0); }
public bool AtLeast(TrackedBundleVersionInfo info2) { return(compareTo(this, info2) >= 0); }
public static int StringBasedCompareTo(TrackedBundleVersionInfo info1, TrackedBundleVersionInfo info2) { System.Version v1 = new System.Version(info1.version); System.Version v2 = new System.Version(info2.version); return(v1.CompareTo(v2)); }
public bool Before(TrackedBundleVersionInfo info2) { return compareTo (this, info2) < 0; }
public bool AtLeast(TrackedBundleVersionInfo info2) { return compareTo (this, info2) >= 0; }
/// <summary> /// Compares the given version info objects according to IComparable specs: /// http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx. /// </summary> /// <returns> /// 0 on equality, -1 if info1 is older than info2, +1 if it's newer. /// Every object is greater than null and both null means equal. /// </returns> /// <param name='info1'> /// Info1. /// </param> /// <param name='info2'> /// Info2. /// </param> public static int DefaultCompareTo(TrackedBundleVersionInfo info1, TrackedBundleVersionInfo info2) { if ((object)info1 == null || (object)info2 == null) { return ((object)info1 == null ? -1 : 0) + ((object)info2 == null ? 1 : 0); } // if both versions are not contained in TrackedBundleVersion.history perform a string compare // otherwise the non-registered is treated as older if (info1.index < 0 && info2.index < 0) { return System.String.Compare (info1.version, info2.version); // NOTE: we rely on index only; if history is manipulated manually this will lead to problems; // Provide a customised version and set it to static member compareTo } else if (info1.index > info2.index) { return 1; } else if (info1.index < info2.index) { return -1; } else { return 0; } }