我已经以下代码:访问包裹方法属性
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]将不被执行。
如何才能找到方法只是包装和基础方法包含属性以及如何访问此属性?
这是另一种情况当我没有想到相当明显的解决方案:)谢谢:)不幸的是,我有更多类似的方法,如ProcessStep,ProcessStep,ProcessStep + TParams,现在代码看起来很丑,所以我会找到没有该属性的解决方案。 –
prostynick
2010-03-17 12:55:38