Ninject 拦截类 X 的所有实例
我正在尝试 AOP 的各种框架实现,并且我真的很喜欢 Ninject,但是有一个标准我一生都无法实现。
我试图让它对所有属于 typeof(X) 的类使用拦截器...这是我当前的代码:
Kernel.Intercept(x => x.Binding.Target.GetType().IsInstanceOfType(typeof(X))).With<SomeInterceptor>();
我最初尝试使用 x.Request.Blah 与 x.Binding.Blah 相反,但这两种方法似乎都不起作用产生我想要的结果...这个令人惊奇的功能的文档非常稀缺,并且似乎从未涵盖 Kernel.Intercept() 扩展...
希望这是一个简单的答案!
I am trying out various frameworks implementations for AOP and I am really liking Ninject, however there is one criteria I just cannot get working for the life of me.
I am trying to get it to use an interceptor against all classes that are a typeof(X)... Here is my current code:
Kernel.Intercept(x => x.Binding.Target.GetType().IsInstanceOfType(typeof(X))).With<SomeInterceptor>();
I was originally trying x.Request.Blah opposed to x.Binding.Blah however neither way seemed to yield the results I was after... and the documentation for this amazing functionality is quite scarce and never seems to cover the Kernel.Intercept() extension...
Hopefully it is a simple answer!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
x.Binding.Target
是一个指定提供程序类型的枚举。您必须查看 x.Binding.Service ,它是绑定类型。如果您需要实例化类型,则必须等待下一个版本。x.Binding.Target
is an enum that specifies the type of the provider. You have to look atx.Binding.Service
which is the bound type. If you need the instantiated type you have to wait for the next release.