:1つのメソッドを決定する方法 "Typeの拡張メソッドかどうか"
public bool IsExtensionMethod(object anObject, string method)
{
// if method was an extension for anObject return true else false
}
私はそれをどのように行うことができますか?
私は、次のコードを試みたが、いくつかのケースでは、戻り値が正しくないです。
public bool IsExtensionMethod(object anObject, string method)
{
return anObject.GetType().GetMethods().Where(item => item.Name == method).Count() == 0;
}
可能重複(http://stackoverflow.com/questions/721800/using-reflection-to-check-if-a- method-is-extension-method) –