private static bool MethodMatch(MethodInfo candidate, MethodInfo method) { if (candidate.Name != method.Name) { return(false); } if (!QueryableTransformer.HasExtensionAttribute(candidate)) { return(false); } Type[] parameterTypes = method.GetParameterTypes(); if (parameterTypes.Length != candidate.GetParameters().Length) { return(false); } if (method.IsGenericMethod) { if (!candidate.IsGenericMethod) { return(false); } if (candidate.GetGenericArguments().Length != method.GetGenericArguments().Length) { return(false); } candidate = candidate.MakeGenericMethodFrom(method); } if (!QueryableTransformer.TypeMatch(candidate.ReturnType, method.ReturnType)) { return(false); } Type[] parameterTypes2 = candidate.GetParameterTypes(); if (parameterTypes2[0] != QueryableTransformer.GetComparableType(parameterTypes[0])) { return(false); } for (int i = 1; i < parameterTypes2.Length; i++) { if (!QueryableTransformer.TypeMatch(parameterTypes2[i], parameterTypes[i])) { return(false); } } return(true); }
private static bool TypeMatch(Type candidate, Type type) { return(candidate == type || candidate == QueryableTransformer.GetComparableType(type)); }