public override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria) { return(RewriteConstructors(RuntimeType.FindMembers(memberType, bindingAttr, filter, filterCriteria))); }
internal void ResolveMethod(bool bThrowIfNotResolved) { if (this.MI != null || this.methodName == null) { return; } RuntimeType t = this.ResolveType() as RuntimeType; if (this.methodName.Equals(".ctor")) { return; } if (t == null) { throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), (object)this.typeName)); } if (this.methodSignature != null) { try { this.MI = (MethodBase)t.GetMethod(this.methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null, CallingConventions.Any, this.methodSignature, (ParameterModifier[])null); } catch (AmbiguousMatchException ex) { MemberInfo[] members = t.FindMembers(MemberTypes.Method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.FilterName, (object)this.methodName); int num = this.instArgs == null ? 0 : this.instArgs.Length; int length = 0; for (int index = 0; index < members.Length; ++index) { MethodInfo methodInfo = (MethodInfo)members[index]; if ((methodInfo.IsGenericMethod ? methodInfo.GetGenericArguments().Length : 0) == num) { if (index > length) { members[length] = members[index]; } ++length; } } MethodInfo[] methodInfoArray = new MethodInfo[length]; for (int index = 0; index < length; ++index) { methodInfoArray[index] = (MethodInfo)members[index]; } this.MI = Type.DefaultBinder.SelectMethod(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, (MethodBase[])methodInfoArray, this.methodSignature, (ParameterModifier[])null); } if (this.instArgs != null && this.instArgs.Length > 0) { this.MI = (MethodBase)((MethodInfo)this.MI).MakeGenericMethod(this.instArgs); } } else { RemotingTypeCachedData remotingTypeCachedData = (RemotingTypeCachedData)null; if (this.instArgs == null) { remotingTypeCachedData = InternalRemotingServices.GetReflectionCachedData((Type)t); this.MI = remotingTypeCachedData.GetLastCalledMethod(this.methodName); if (this.MI != null) { return; } } bool flag = false; try { this.MI = (MethodBase)t.GetMethod(this.methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (this.instArgs != null) { if (this.instArgs.Length > 0) { this.MI = (MethodBase)((MethodInfo)this.MI).MakeGenericMethod(this.instArgs); } } } catch (AmbiguousMatchException ex) { flag = true; this.ResolveOverloadedMethod(t); } if (this.MI != null && !flag && remotingTypeCachedData != null) { remotingTypeCachedData.SetLastCalledMethod(this.methodName, this.MI); } } if (this.MI == null && bThrowIfNotResolved) { throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), (object)this.methodName, (object)this.typeName)); } }
internal void ResolveMethod(bool bThrowIfNotResolved) { if ((this.MI == null) && (this.methodName != null)) { RuntimeType mi = this.ResolveType() as RuntimeType; if (!this.methodName.Equals(".ctor")) { if (mi == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), new object[] { this.typeName })); } if (this.methodSignature != null) { bool flag = false; int num = (this.instArgs == null) ? 0 : this.instArgs.Length; if (num == 0) { try { this.MI = mi.GetMethod(this.methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, CallingConventions.Any, this.methodSignature, null); flag = true; } catch (AmbiguousMatchException) { } } if (!flag) { MemberInfo[] infoArray = mi.FindMembers(MemberTypes.Method, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, Type.FilterName, this.methodName); int index = 0; for (int i = 0; i < infoArray.Length; i++) { try { MethodInfo info = (MethodInfo)infoArray[i]; int num4 = info.IsGenericMethod ? info.GetGenericArguments().Length : 0; if (num4 == num) { if (num > 0) { info = info.MakeGenericMethod(this.instArgs); } infoArray[index] = info; index++; } } catch (ArgumentException) { } catch (VerificationException) { } } MethodInfo[] match = new MethodInfo[index]; for (int j = 0; j < index; j++) { match[j] = (MethodInfo)infoArray[j]; } this.MI = Type.DefaultBinder.SelectMethod(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, match, this.methodSignature, null); } } else { RemotingTypeCachedData reflectionCachedData = null; if (this.instArgs == null) { reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(mi); this.MI = reflectionCachedData.GetLastCalledMethod(this.methodName); if (this.MI != null) { return; } } bool flag2 = false; try { this.MI = mi.GetMethod(this.methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if ((this.instArgs != null) && (this.instArgs.Length > 0)) { this.MI = ((MethodInfo)this.MI).MakeGenericMethod(this.instArgs); } } catch (AmbiguousMatchException) { flag2 = true; this.ResolveOverloadedMethod(mi); } if (((this.MI != null) && !flag2) && (reflectionCachedData != null)) { reflectionCachedData.SetLastCalledMethod(this.methodName, this.MI); } } if ((this.MI == null) && bThrowIfNotResolved) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), new object[] { this.methodName, this.typeName })); } } } }
internal void ResolveMethod(bool bThrowIfNotResolved) { if (this.MI == null && this.methodName != null) { RuntimeType runtimeType = this.ResolveType() as RuntimeType; if (this.methodName.Equals(".ctor")) { return; } if (runtimeType == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), this.typeName)); } if (this.methodSignature != null) { bool flag = false; int num = (this.instArgs == null) ? 0 : this.instArgs.Length; if (num == 0) { try { this.MI = runtimeType.GetMethod(this.methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, this.methodSignature, null); flag = true; } catch (AmbiguousMatchException) { } } if (!flag) { MemberInfo[] array = runtimeType.FindMembers(MemberTypes.Method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.FilterName, this.methodName); int num2 = 0; for (int i = 0; i < array.Length; i++) { try { MethodInfo methodInfo = (MethodInfo)array[i]; int num3 = methodInfo.IsGenericMethod ? methodInfo.GetGenericArguments().Length : 0; if (num3 == num) { if (num > 0) { methodInfo = methodInfo.MakeGenericMethod(this.instArgs); } array[num2] = methodInfo; num2++; } } catch (ArgumentException) { } catch (VerificationException) { } } MethodInfo[] array2 = new MethodInfo[num2]; for (int j = 0; j < num2; j++) { array2[j] = (MethodInfo)array[j]; } this.MI = Type.DefaultBinder.SelectMethod(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, array2, this.methodSignature, null); } } else { RemotingTypeCachedData remotingTypeCachedData = null; if (this.instArgs == null) { remotingTypeCachedData = InternalRemotingServices.GetReflectionCachedData(runtimeType); this.MI = remotingTypeCachedData.GetLastCalledMethod(this.methodName); if (this.MI != null) { return; } } bool flag2 = false; try { this.MI = runtimeType.GetMethod(this.methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (this.instArgs != null && this.instArgs.Length != 0) { this.MI = ((MethodInfo)this.MI).MakeGenericMethod(this.instArgs); } } catch (AmbiguousMatchException) { flag2 = true; this.ResolveOverloadedMethod(runtimeType); } if (this.MI != null && !flag2 && remotingTypeCachedData != null) { remotingTypeCachedData.SetLastCalledMethod(this.methodName, this.MI); } } if (this.MI == null && bThrowIfNotResolved) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), this.methodName, this.typeName)); } } }