开发者

Ninject Intercept all instances of class X

I am trying开发者_Python百科 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!


x.Binding.Target is an enum that specifies the type of the provider. You have to look at x.Binding.Service which is the bound type. If you need the instantiated type you have to wait for the next release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜