如何確定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