public static IEnumerable <MethodBase> FilterMethods(MethodFilter filter, MethodInfo[] allMethods) { List <MethodBase> methodBases = new List <MethodBase>(); CallingConventions reflectionCallingConvention = SignatureUtil.GetReflectionCallingConvention(filter.CallingConvention); MethodInfo[] methodInfoArray = allMethods; for (int i = 0; i < (int)methodInfoArray.Length; i++) { MethodInfo methodInfo = methodInfoArray[i]; if (methodInfo.Name.Equals(filter.Name, StringComparison.Ordinal) && SignatureUtil.IsCallingConventionMatch(methodInfo, reflectionCallingConvention) && SignatureUtil.IsGenericParametersCountMatch(methodInfo, filter.GenericParameterCount) && (int)methodInfo.GetParameters().Length == filter.ParameterCount) { methodBases.Add(methodInfo); } } return(methodBases); }
public static IEnumerable <MethodBase> FilterConstructors(MethodFilter filter, ConstructorInfo[] allConstructors) { List <MethodBase> methodBases = new List <MethodBase>(); CallingConventions reflectionCallingConvention = SignatureUtil.GetReflectionCallingConvention(filter.CallingConvention); ConstructorInfo[] constructorInfoArray = allConstructors; for (int i = 0; i < (int)constructorInfoArray.Length; i++) { ConstructorInfo constructorInfo = constructorInfoArray[i]; if (constructorInfo.Name.Equals(filter.Name, StringComparison.Ordinal) && SignatureUtil.IsCallingConventionMatch(constructorInfo, reflectionCallingConvention) && (int)constructorInfo.GetParameters().Length == filter.ParameterCount) { methodBases.Add(constructorInfo); } } return(methodBases); }