I am trying to implement nhibernate transaction handling through Interceptors and couldn't figure out how to register the interface through fluent mechanism.
I see a
Component.For<ServicesInterceptor>().Interceptors
but not sure how to use it. Can someone help me out? This example seemed a little complex.
You do it in two steps:
container.Register(Component.For<MyInterceptor>());
Interceptors
method on fluent API you specify which of the registered interceptors (by key, or type) you want to intercept this component with: container.Register(Component.For<IFoo>().ImplementedBy<Foo>() .Interceptors<MyInterceptor>());
See the documentation for more details.
First register the interceptor:
container.Register(Component.For<IDbInterceptor>().ImplementedBy<DbInterceptor>().Named("transactionInterceptor"));
Then register the objecting being intercepted:
container.Register(Component.For<IMyService>().ImplementedBy<MyService>().Named("MyService"). Interceptors(new InterceptorReference("transactionInterceptor")).Anywhere);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.