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
Post a Comment