[英]Register an Interceptor with Castle Fluent Interface
我正在尝试通过拦截器实现nhibernate事务处理 ,但无法弄清楚如何通过流畅的机制注册接口。
我看到一个
Component.For<ServicesInterceptor>().Interceptors
但不确定如何使用。 有人可以帮我吗? 这个例子似乎有点复杂。
您分两个步骤进行操作:
container.Register(Component.For<MyInterceptor>());
Interceptors
方法,您可以指定要使用以下哪个拦截器(按键或类型)拦截该组件: container.Register(Component.For<IFoo>().ImplementedBy<Foo>() .Interceptors<MyInterceptor>());
有关更多详细信息,请参见文档 。
首先注册拦截器:
container.Register(Component.For<IDbInterceptor>().ImplementedBy<DbInterceptor>().Named("transactionInterceptor"));
然后注册被拦截的对象:
container.Register(Component.For <IMyService>()。ImplementedBy <MyService>()。Named(“ MyService”)。Interceptors(new InterceptorReference(“ transactionInterceptor”))。Anywhere);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.