private static int FindMostSpecific(ParameterInfo[] p1, int[] paramOrder1, Type paramArrayType1, ParameterInfo[] p2, int[] paramOrder2, Type paramArrayType2, Type[] types, object[] args) { if (paramArrayType1 != (Type)null && paramArrayType2 == (Type)null) { return(2); } if (paramArrayType2 != (Type)null && paramArrayType1 == (Type)null) { return(1); } bool flag1 = false; bool flag2 = false; for (int index = 0; index < types.Length; ++index) { if (args == null || args[index] != Type.Missing) { Type c1 = !(paramArrayType1 != (Type)null) || paramOrder1[index] < p1.Length - 1 ? p1[paramOrder1[index]].ParameterType : paramArrayType1; Type c2 = !(paramArrayType2 != (Type)null) || paramOrder2[index] < p2.Length - 1 ? p2[paramOrder2[index]].ParameterType : paramArrayType2; if (!(c1 == c2)) { switch (DefaultBinder.FindMostSpecificType(c1, c2, types[index])) { case 0: return(0); case 1: flag1 = true; continue; case 2: flag2 = true; continue; default: continue; } } } } if (flag1 == flag2) { if (!flag1 && args != null) { if (p1.Length > p2.Length) { return(1); } if (p2.Length > p1.Length) { return(2); } } return(0); } return(!flag1 ? 2 : 1); }
// Token: 0x06000D9A RID: 3482 RVA: 0x00029A74 File Offset: 0x00027C74 private static int FindMostSpecific(ParameterInfo[] p1, int[] paramOrder1, Type paramArrayType1, ParameterInfo[] p2, int[] paramOrder2, Type paramArrayType2, Type[] types, object[] args) { if (paramArrayType1 != null && paramArrayType2 == null) { return(2); } if (paramArrayType2 != null && paramArrayType1 == null) { return(1); } bool flag = false; bool flag2 = false; for (int i = 0; i < types.Length; i++) { if (args == null || args[i] != Type.Missing) { Type type; if (paramArrayType1 != null && paramOrder1[i] >= p1.Length - 1) { type = paramArrayType1; } else { type = p1[paramOrder1[i]].ParameterType; } Type type2; if (paramArrayType2 != null && paramOrder2[i] >= p2.Length - 1) { type2 = paramArrayType2; } else { type2 = p2[paramOrder2[i]].ParameterType; } if (!(type == type2)) { switch (DefaultBinder.FindMostSpecificType(type, type2, types[i])) { case 0: return(0); case 1: flag = true; break; case 2: flag2 = true; break; } } } } if (flag == flag2) { if (!flag && args != null) { if (p1.Length > p2.Length) { return(1); } if (p2.Length > p1.Length) { return(2); } } return(0); } if (!flag) { return(2); } return(1); }
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers) { if (indexes != null) { if (!Contract.ForAll <Type>(indexes, (Type t) => t != null)) { Exception ex = new ArgumentNullException("indexes"); throw ex; } } if (match == null || match.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match"); } PropertyInfo[] array = (PropertyInfo[])match.Clone(); int i = 0; int num = 0; int num2 = (indexes != null) ? indexes.Length : 0; int j = 0; while (j < array.Length) { if (indexes == null) { goto IL_118; } ParameterInfo[] indexParameters = array[j].GetIndexParameters(); if (indexParameters.Length == num2) { for (i = 0; i < num2; i++) { Type parameterType = indexParameters[i].ParameterType; if (!(parameterType == indexes[i]) && !(parameterType == typeof(object))) { if (parameterType.IsPrimitive) { if (!(indexes[i].UnderlyingSystemType is RuntimeType)) { break; } if (!DefaultBinder.CanConvertPrimitive((RuntimeType)indexes[i].UnderlyingSystemType, (RuntimeType)parameterType.UnderlyingSystemType)) { break; } } else if (!parameterType.IsAssignableFrom(indexes[i])) { break; } } } goto IL_118; } IL_182: j++; continue; IL_118: if (i == num2) { if (returnType != null) { if (array[j].PropertyType.IsPrimitive) { if (!(returnType.UnderlyingSystemType is RuntimeType)) { goto IL_182; } if (!DefaultBinder.CanConvertPrimitive((RuntimeType)returnType.UnderlyingSystemType, (RuntimeType)array[j].PropertyType.UnderlyingSystemType)) { goto IL_182; } } else if (!array[j].PropertyType.IsAssignableFrom(returnType)) { goto IL_182; } } array[num++] = array[j]; goto IL_182; } goto IL_182; } if (num == 0) { return(null); } if (num == 1) { return(array[0]); } int num3 = 0; bool flag = false; int[] array2 = new int[num2]; for (j = 0; j < num2; j++) { array2[j] = j; } for (j = 1; j < num; j++) { int num4 = DefaultBinder.FindMostSpecificType(array[num3].PropertyType, array[j].PropertyType, returnType); if (num4 == 0 && indexes != null) { num4 = DefaultBinder.FindMostSpecific(array[num3].GetIndexParameters(), array2, null, array[j].GetIndexParameters(), array2, null, indexes, null); } if (num4 == 0) { num4 = DefaultBinder.FindMostSpecificProperty(array[num3], array[j]); if (num4 == 0) { flag = true; } } if (num4 == 2) { flag = false; num3 = j; } } if (flag) { throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); } return(array[num3]); }
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers) { if (indexes != null) { Type[] typeArray = indexes; Predicate <Type> predicate1 = (Predicate <Type>)(t => t != (Type)null); Predicate <Type> predicate2; if (!Contract.ForAll <Type>((IEnumerable <Type>)typeArray, predicate2)) { throw new ArgumentNullException("indexes"); } } if (match == null || match.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match"); } PropertyInfo[] propertyInfoArray = (PropertyInfo[])match.Clone(); int index1 = 0; int num1 = 0; int length = indexes != null ? indexes.Length : 0; for (int index2 = 0; index2 < propertyInfoArray.Length; ++index2) { if (indexes != null) { ParameterInfo[] indexParameters = propertyInfoArray[index2].GetIndexParameters(); if (indexParameters.Length == length) { for (index1 = 0; index1 < length; ++index1) { Type parameterType = indexParameters[index1].ParameterType; if (!(parameterType == indexes[index1]) && !(parameterType == typeof(object))) { if (parameterType.IsPrimitive) { if (!(indexes[index1].UnderlyingSystemType is RuntimeType) || !DefaultBinder.CanConvertPrimitive((RuntimeType)indexes[index1].UnderlyingSystemType, (RuntimeType)parameterType.UnderlyingSystemType)) { break; } } else if (!parameterType.IsAssignableFrom(indexes[index1])) { break; } } } } else { continue; } } if (index1 == length) { if (returnType != (Type)null) { if (propertyInfoArray[index2].PropertyType.IsPrimitive) { if (!(returnType.UnderlyingSystemType is RuntimeType) || !DefaultBinder.CanConvertPrimitive((RuntimeType)returnType.UnderlyingSystemType, (RuntimeType)propertyInfoArray[index2].PropertyType.UnderlyingSystemType)) { continue; } } else if (!propertyInfoArray[index2].PropertyType.IsAssignableFrom(returnType)) { continue; } } propertyInfoArray[num1++] = propertyInfoArray[index2]; } } if (num1 == 0) { return((PropertyInfo)null); } if (num1 == 1) { return(propertyInfoArray[0]); } int index3 = 0; bool flag = false; int[] numArray = new int[length]; for (int index2 = 0; index2 < length; ++index2) { numArray[index2] = index2; } for (int index2 = 1; index2 < num1; ++index2) { int num2 = DefaultBinder.FindMostSpecificType(propertyInfoArray[index3].PropertyType, propertyInfoArray[index2].PropertyType, returnType); if (num2 == 0 && indexes != null) { num2 = DefaultBinder.FindMostSpecific(propertyInfoArray[index3].GetIndexParameters(), numArray, (Type)null, propertyInfoArray[index2].GetIndexParameters(), numArray, (Type)null, indexes, (object[])null); } if (num2 == 0) { num2 = DefaultBinder.FindMostSpecificProperty(propertyInfoArray[index3], propertyInfoArray[index2]); if (num2 == 0) { flag = true; } } if (num2 == 2) { flag = false; index3 = index2; } } if (flag) { throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); } return(propertyInfoArray[index3]); }