c# - Castle Windsor Interceptors and Registering by Convention -


i'm using castle windsor manage dependencies application.

i'm using classes.fromassemblycontaining register components of given type ifoo<> , register interceptor of these classes.

i can interceptor work when register individual components this:

public void setupcontainer(iwindsorcontainer container) {     container.register(component.for<ifoo>()                                 .implementedby<foo>()                                 .lifestylesingleton().interceptors<myintercepter>()); } 

however keep registering convention using classes.fromassembly. registration code looks this:

public void setupcontainer(iwindsorcontainer container) {      container.register(classes.fromassemblycontaining<foo>()                                .basedon(typeof(ifoo<>))                                .withservice.base()); } 

how add interceptor ifoo<>'s registered?

you use configure method add interceptor:

public void setupcontainer(iwindsorcontainer container) {     container.register(classes.fromassemblycontaining<foo>()                               .basedon(typeof(ifoo<>))                               .withservice.base()                               .configure(r => r.interceptors<foointerceptor>())); } 

i needed register interceptor:

container.register(component.for<foointerceptor>()); 

but presumably you'd registering elsewhere (by convention).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -