public static int MethodInfoComparison(MethodInfoAndIndex mi1, MethodInfoAndIndex mi2) { MethodInfo m1 = mi1.method; MethodInfo m2 = mi2.method; if (!m1.IsStatic && m2.IsStatic) { return(-1); } if (m1.IsStatic && !m2.IsStatic) { return(1); } if (m1.Name != m2.Name) { return(string.Compare(m1.Name, m2.Name)); } int max1 = 0; { ParameterInfo[] ps = m1.GetParameters(); if (ps.Length > 0) { max1 = ps.Length; } for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) { break; } max1--; } } int max2 = 0; { ParameterInfo[] ps = m2.GetParameters(); if (ps.Length > 0) { max2 = ps.Length; } for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) { break; } max2--; } } if (max1 > max2) { return(-1); } if (max2 > max1) { return(1); } return(0); }
public static int MethodInfoComparison(MethodInfoAndIndex mi1, MethodInfoAndIndex mi2) { MethodInfo m1 = mi1.method; MethodInfo m2 = mi2.method; if (!m1.IsStatic && m2.IsStatic) return -1; if (m1.IsStatic && !m2.IsStatic) return 1; if (m1.Name != m2.Name) return string.Compare(m1.Name, m2.Name); int max1 = 0; { ParameterInfo[] ps = m1.GetParameters(); if (ps.Length > 0) max1 = ps.Length; for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) break; max1--; } } int max2 = 0; { ParameterInfo[] ps = m2.GetParameters(); if (ps.Length > 0) max2 = ps.Length; for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) break; max2--; } } if (max1 > max2) return -1; if (max2 > max1) return 1; return 0; }
public static int MethodInfoComparison(MethodInfoAndIndex mi1, MethodInfoAndIndex mi2) { var result = JsFrameworkUpgrade.MethodInfoComparison(mi1, mi2); if (result != 0) { return(result); } var m1 = mi1.method; var m2 = mi2.method; if (!m1.IsStatic && m2.IsStatic) { return(-1); } if (m1.IsStatic && !m2.IsStatic) { return(1); } if (m1.Name != m2.Name) { return(string.Compare(m1.Name, m2.Name)); } int max1 = 0; { var ps = m1.GetParameters(); if (ps.Length > 0) { max1 = ps.Length; } for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) { break; } max1--; } } int max2 = 0; { var ps = m2.GetParameters(); if (ps.Length > 0) { max2 = ps.Length; } for (int i = ps.Length - 1; i >= 0; i--) { if (!ps[i].IsOptional) { break; } max2--; } } if (max1 > max2) { return(-1); } if (max2 > max1) { return(1); } return(0); }