Beispiel #1
0
        /// <summary>
        /// Compares two instances
        /// </summary>
        /// <param name="x">First instance to compare</param>
        /// <param name="y">Second instance to compare</param>
        /// <returns></returns>
        public int Compare([AllowNull] IMethod x, [AllowNull] IMethod y)
        {
            if ((object?)x == y)
            {
                return(0);
            }
            if (x is null)
            {
                return(-1);
            }
            if (y is null)
            {
                return(1);
            }
            string xn   = x.Name;
            string yn   = y.Name;
            int    xacc = GetAccessor(xn, out var xPropName);
            int    yacc = GetAccessor(yn, out var yPropName);
            int    c    = StringComparer.OrdinalIgnoreCase.Compare(xPropName, yPropName);

            if (c != 0)
            {
                return(c);
            }
            c = xacc - yacc;
            if (c != 0)
            {
                return(c);
            }
            return(MethodRefComparer.CompareNoName(x, y));
        }
Beispiel #2
0
        /// <summary>
        /// Compares two instances
        /// </summary>
        /// <param name="x">First instance to compare</param>
        /// <param name="y">Second instance to compare</param>
        /// <returns></returns>
        public int Compare(IMethod x, IMethod y)
        {
            string xn   = x.Name;
            string yn   = y.Name;
            int    xacc = GetAccessor(xn, out var xPropName);
            int    yacc = GetAccessor(yn, out var yPropName);
            int    c    = StringComparer.OrdinalIgnoreCase.Compare(xPropName, yPropName);

            if (c != 0)
            {
                return(c);
            }
            c = xacc - yacc;
            if (c != 0)
            {
                return(c);
            }
            return(MethodRefComparer.CompareNoName(x, y));
        }