When registering a component use the Interceptors()
method to specify what are the interceptors/types of interceptors to be used for this component:
The TInterceptor
must implement the IInterceptor
interface
A single interceptor by type:
container.Register(
Component.For<MyInterceptor>(),
Component.For<IFoo>()
.ImplementedBy<Foo>()
.Interceptors<MyInterceptor>());
Two interceptors by type:
container.Register(
Component.For<MyInterceptor1>(),
Component.For<MyInterceptor2>(),
Component.For<IFoo>()
.ImplementedBy<Foo>()
.Interceptors<MyInterceptor1, MyInterceptor2>());
More than 2 interceptors by type:
container.Register(
Component.For<MyInterceptor1>(),
Component.For<MyInterceptor2>(),
Component.For<MyInterceptor3>(),
Component.For<IFoo>()
.ImplementedBy<Foo>()
.Interceptors(typeof(MyInterceptor1),
typeof(MyInterceptor2),
typeof(MyInterceptor3)));