Accessing wrapped method attribute in C#
- by prostynick
I have following code:
public static void ProcessStep(Action action)
{
//do something here
if (Attribute.IsDefined(action.Method, typeof(LogAttribute)))
{
//do something here [1]
}
action();
//do something here
}
For easy use I have some similar methods using method above. For example:
public static void ProcessStep(Action<bool> action)
{
ProcessStep(() => action(true)); //this is only example, don't bother about hardcoded true
}
But when I use the second method (the one above), even if original action had attribute, code [1] will not be executed.
How can I find if method is only wrapper and underlying method contains attribute and how to access this attribute?