Access custom attribute on method from Castle Windsor interceptor

Posted by RobW on Stack Overflow See other posts from Stack Overflow or by RobW
Published on 2010-03-29T08:42:55Z Indexed on 2010/03/29 11:53 UTC
Read the original article Hit count: 817

I am trying to access a custom attribute applied to a method within a castle interceptor, e.g.:

[MyCustomAttribute(SomeParam = "attributeValue")]
public virtual MyEntity Entity { get; set; }

using the following code:

internal class MyInterceptor : IInterceptor
{
    public void Intercept(IInvocation invocation)
    {
        if (invocation.Method.GetCustomAttributes(typeof(MyCustomAttribute), true) != null)
        {
            //Do something
        }
    }
}

The interceptor is firing OK when the method is called but this code does not return the custom attribute. How can I achieve this?

© Stack Overflow or respective owner

Related posts about castle-windsor

Related posts about interceptor