我有以下代码:
public static void ProcessStep(Action action)
{
//do something here
if (Attribute.IsDefined(action.Method, typeof(LogAttribute)))
{
//do something here [1]
}
action();
//do something here
}
为了方便使用,我有一些类似的方法使用上面的方法。例如:
public static void ProcessStep(Action<bool> action)
{
ProcessStep(() => action(true)); //this is only example, don't bother about hardcoded true
}
但是当我使用第二种方法(上面的那个)时,即使原来的动作有属性,代码[1]也不会被执行。
如何查找方法是否只是包装器并且底层方法是否包含属性以及如何访问该属性?