This is function which checks which delegate should be bound to which method: Description is here
private static bool IsEquivalent(Delegate d, MethodInfo method)
{
var dm = d.Method;
if (!method.ReturnType.IsAssignableFrom(dm.ReturnType))
return false;
var parameters = method.GetParameters();
var dp = dm.GetParameters();
if (parameters.Length != dp.Length)
return false;
for (int i = 0; i < parameters.Length; i++)
{
//BUG: does not take into account modifiers (like out, ref...)
if (!parameters[i].ParameterType.IsAssignableFrom(dp[i].ParameterType))
return false;
}
return true;
}
Here it checks that method return type and method parameters type are same as the one of the function, which is pointed by delegate. But what if there would be more than one function with the same parameter types? How can we deal in that case? Is it possible to read the function name, which some delegate points to it?