如何确定MethodInfo是否适合不同的委托类型?根据委托检查MethodInfo
bool IsMyDelegate(MethodInfo method);
编辑: 我给一个MethodInfo对象,想知道它是否符合委托接口。 除了明显
private bool IsValidationDelegate(MethodInfo method)
{
var result = false;
var parameters = method.GetParameters();
if (parameters.Length == 2 &&
parameters[0].ParameterType == typeof(MyObject1) &&
parameters[1].ParameterType == typeof(MyObject2) &&
method.ReturnType == typeof(bool))
{
result = true;
}
else
{
m_Log.Error("Validator:IsValidationDelegate", "Method [...] is not a ValidationDelegate.");
}
return result;
}
您能否重新说明您的问题。目前还不清楚你想知道什么。 – Steven 2010-02-08 11:11:50
有帮助吗? – 2010-02-08 11:15:08
你是否要求编译时支持? – Steven 2010-02-08 11:19:12