Configure windsor interceptor to hook only marked methods

筅森魡賤 提交于 2020-02-05 05:15:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!