Reputation: 16209
Documentation says that I can apply multiple Interceptor
attributes per class. Nevertheless I'm getting an syntax error duplicated attribute. Also this post suggest that I can apply interceptors to methods, but I can't! My tests only pass if I apply them to the class, what is moreover annoying if I want interceptors to be executed only for certain methods.
[Interceptor (typeof (CastleWindsorAspect))]
[Interceptor (typeof (AnotherCastleWindsorAspect))]
public class CastleWindsorDomainType { }
Upvotes: 0
Views: 848
Reputation: 27384
You do indeed can apply multiple interceptors to a component. You can do it using the fluent registration API and using the XML config.
You should also be able to do it via custom attributes, like you demonstrated, but it would appear there's a bug in Windsor that doesn't allow you to specify it multiple times (hence the error you're seeing). I would recommend reporting this as a bug and use the registration API to attach multiple intereceptors in the meantime.
As for applying interceptors to methods you can do that, but not declaratively. Instead you'd need to specify IProxyGenerationHook
or IInterceptorsSelector
to control which methods should be proxied and/or which interceptors should be applied to which of the proxied methods.
Upvotes: 1