问题
Is there possibility to configure Interceptor to hook methods only of special interface, or by base class? Currently I have registered Interceptor that works with scope of connections to one DB. Now I added another scope working with another db and want to add another interceptor, which will hook methods of second scope. It is possible to configure interceptor via xml files, instead of checking target of invocation properties.
I've added interceptor via components:
<component
type="Common.IoC.SessionScopeInterceptor, Common"
lifestyle="transient">
</component>
AFAIK this interceptor intercepts all methods of all classes registered in windsor container.
I wand to add something like this^
<component
type="Common.IoC.SessionScopeInterceptor, Common"
lifestyle="transient"
interceptOnlyVirtualMethods="true"
interceptClass="Common.IoC.SessionScope1, Common"
>
</component>
回答1:
you need to create your own AbstractFacility that implements your desired behaviour. Essentially, you need to implement something similar to what Mikael Sundberg did in the answer to this question.
来源:https://stackoverflow.com/questions/10547690/configure-windsor-interceptor-to-hook-only-marked-methods