Ninject Intercept all instances of class X

330 views Asked by At

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!

1

There are 1 answers

1
Remo Gloor On BEST 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.