Example #1
0
        /// <summary>
        /// Compares two assembly names
        /// </summary>
        /// <param name="a">First</param>
        /// <param name="b">Second</param>
        /// <returns>&lt; 0 if a &lt; b, 0 if a == b, &gt; 0 if a &gt; b</returns>
        public int CompareTo(IAssembly a, IAssembly b)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }

            int v;

            if (CompareName && (v = UTF8String.CaseInsensitiveCompareTo(a.Name, b.Name)) != 0)
            {
                return(v);
            }
            if (CompareVersion && (v = Utils.CompareTo(a.Version, b.Version)) != 0)
            {
                return(v);
            }
            if (ComparePublicKeyToken && (v = PublicKeyBase.TokenCompareTo(a.PublicKeyOrToken, b.PublicKeyOrToken)) != 0)
            {
                return(v);
            }
            if (CompareCulture && (v = Utils.LocaleCompareTo(a.Culture, b.Culture)) != 0)
            {
                return(v);
            }
            if (CompareContentType && (v = a.ContentType.CompareTo(b.ContentType)) != 0)
            {
                return(v);
            }

            return(0);
        }
        /// <summary>
        /// Compares two assembly names
        /// </summary>
        /// <param name="a">First</param>
        /// <param name="b">Second</param>
        /// <returns>&lt; 0 if a &lt; b, 0 if a == b, &gt; 0 if a &gt; b</returns>
        public int CompareTo(AssemblyNameInfo a, AssemblyNameInfo b)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }

            int v;

            if (CompareName && (v = UTF8String.CaseInsensitiveCompareTo(a.Name, b.Name)) != 0)
            {
                return(v);
            }
            if (CompareVersion && (v = Utils.CompareTo(a.Version, b.Version)) != 0)
            {
                return(v);
            }
            if (ComparePublicKeyToken && (v = PublicKeyBase.TokenCompareTo(a.PublicKeyOrToken, b.PublicKeyOrToken)) != 0)
            {
                return(v);
            }
            if (CompareLocale && (v = Utils.LocaleCompareTo(a.Locale, b.Locale)) != 0)
            {
                return(v);
            }

            return(0);
        }