Reputation: 29
Given the following code:
container.Register(
AllTypes.FromAssemblyNamed("MyNameSpace")
.Where(component => component.Name.EndsWith("Repository"))
.WithService.FirstInterface()
.Configure(component => component.LifeStyle.Singleton)
);
Is it possible to introduce an Interceptor(eg LoggingInterceptor) for all components found? My only recourse now is to break each components and add the Interceptor explicitly, which I found counter intuitive since they'll be using one interceptor(ie LoggingInterceptor).
Thanks
Upvotes: 1
Views: 517
Reputation: 581
container.Register(
AllTypes.FromAssemblyNamed("MyNameSpace")
.Where(component => component.Name.EndsWith("Repository"))
.WithService.FirstInterface()
.Configure(component => component.LifeStyle.Singleton.Interceptors(InterceptorReference.ForType<LoggingInterceptor>()))
);
container.Register(Component.For<LoggingInterceptor>());
Upvotes: 1