Need architectural solution - Ninject Interception only works on classes in the kernel

78 views Asked by At

I am working in an asp.net mvc application that uses Ninject for DI. I have been attempting to implement Ninject Interception for logging, following this 2-part article. http://codepyre.com/2010/03/using-ninject-extensions-interception-part-1-the-basics/. I have tried both the method registration and attribute approaches, but neither approach will let me intercept methods on classes that aren't registered in the kernel.

The problem is that mine is a multi-tenant system where I often have to do different concrete operations depending on the client who is logged in. I execute the correct functionality using the Factory Pattern to give me the right class for each client as needed. However, the classes served up by the Factory are not in the kernel and therefore cannot be intercepted.

I'm looking for any sort of solution to this problem including an architectural rework if necessary, so that I can make everything Interceptable.

1

There are 1 answers

0
jgauffin On BEST ANSWER

What you probably are looking for is aspect oriented programming (AOP) libraries.

Look at this question: What Aspect-Oriented Programming (AOP) libraries for .NET are still actively developed?