I am using Ninject as my MVC contr开发者_高级运维oller factory, but I also load in certain routes and controllers via MEF, these controllers need to be able to register themselves with Ninject:
Bind<SomePluginController>.ToSelf();
So the dynamically added routes can be picked up.
So far the only way to do this I can think of is to expose the internal kernel outside of the web application, however this seems a bit nasty and the NinjectHttpApplication.Kernel
seems to be obsolete.
Has anyone else managed to do this?
The problem you've got is that MEF is designed to compose a set of unknown parts, whereas Ninject is dealing with explicit component registration. You can't easily grab type information from MEF because it is all handled at runtime, not compile time.
What I think you may have to do, is build a composite controller factory that supports both Ninject and MEF.
精彩评论