예제 #1
0
            public int Compare(MethodInfo a, MethodInfo b)
            {
                int i;

                ParameterInfo[] aParams = a.GetParameters();
                ParameterInfo[] bParams = b.GetParameters();

                /* Longer signatures match first */
                if (aParams.Length > bParams.Length)
                {
                    return(-1);
                }
                else if (aParams.Length < bParams.Length)
                {
                    return(1);
                }

                /* array sorts first, double, decimal and float, int etc, others */
                for (i = 0; i < aParams.Length; i++)
                {
                    if (aParams[i].ParameterType.IsArray && !bParams[i].ParameterType.IsArray)
                    {
                        return(-1);
                    }
                    else if (!aParams[i].ParameterType.IsArray && bParams[i].ParameterType.IsArray)
                    {
                        return(1);
                    }
                    if (JSObject.IsParamFloating(aParams[i].ParameterType) && !JSObject.IsParamFloating(bParams[i].ParameterType))
                    {
                        return(-1);
                    }
                    else if (!JSObject.IsParamFloating(aParams[i].ParameterType) && JSObject.IsParamFloating(bParams[i].ParameterType))
                    {
                        return(1);
                    }
                    if (JSObject.IsParamIntegral(aParams[i].ParameterType) && !JSObject.IsParamIntegral(bParams[i].ParameterType))
                    {
                        return(-1);
                    }
                    else if (!JSObject.IsParamIntegral(aParams[i].ParameterType) && JSObject.IsParamIntegral(bParams[i].ParameterType))
                    {
                        return(1);
                    }
                }

                return(0);
            }