/// <summary>
/// Returns true if the method's parameter types are reference assignable from
/// the argument types, otherwise false.
///
/// An example that can make the method return false is that
/// typeof(double).GetMethod("op_Equality", ..., new[] { typeof(double), typeof(int) })
/// returns a method with two double parameters, which doesn't match the provided
/// argument types.
/// </summary>
private static bool MatchesArgumentTypes(this MethodInfo mi, Type[] argTypes)
{
Debug.Assert(argTypes != null);
if (mi == null)
{
return(false);
}
ParameterInfo[] ps = mi.GetParametersCached();
if (ps.Length != argTypes.Length)
{
return(false);
}
for (int i = 0; i < ps.Length; i++)
{
if (!TypeUtils.AreReferenceAssignable(ps[i].ParameterType, argTypes[i]))
{
return(false);
}
}
return(true);
}