示例#1
0
		static bool MethodMatch (MethodInfo candidate, MethodInfo method)
		{
			if (candidate.Name != method.Name)
				return false;

			if (!HasExtensionAttribute (candidate))
				return false;

			var parameters = method.GetParameterTypes ();

			if (parameters.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 (!TypeMatch (candidate.ReturnType, method.ReturnType))
				return false;

			var candidate_parameters = candidate.GetParameterTypes ();

			if (candidate_parameters [0] != GetComparableType (parameters [0]))
				return false;

			for (int i = 1; i < candidate_parameters.Length; ++i)
				if (!TypeMatch (candidate_parameters [i], parameters [i]))
					return false;

			return true;
		}
 private static bool MethodMatch(MethodInfo candidate, MethodInfo method)
 {
     if (candidate.Name != method.Name || !HasExtensionAttribute(candidate))
     {
         return false;
     }
     var parameters = method.GetParameterTypes();
     if (parameters.Length != candidate.GetParameters().Length)
     {
         return false;
     }
     else if (method.IsGenericMethod)
     {
         if (!candidate.IsGenericMethod || candidate.GetGenericArguments().Length != method.GetGenericArguments().Length)
         {
             return false;
         }
         candidate = candidate.MakeGenericMethodFrom(method);
     }
     if (!TypeMatch(candidate.ReturnType, method.ReturnType))
     {
         return false;
     }
     var candidate_parameters = candidate.GetParameterTypes();
     if (candidate_parameters[0] != GetComparableType(parameters[0]))
     {
         return false;
     }
     for (int index = 1; index < candidate_parameters.Length; ++index)
     {
         if (!TypeMatch(candidate_parameters[index], parameters[index]))
         {
             return false;
         }
     }
     return true;
 }