Accessing wrapped method attribute in C#
        Posted  
        
            by prostynick
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by prostynick
        
        
        
        Published on 2010-03-17T10:47:44Z
        Indexed on 
            2010/03/17
            10:51 UTC
        
        
        Read the original article
        Hit count: 288
        
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?
© Stack Overflow or respective owner