开发者

Asp Mvc 3 with NinjectHttpApplication and MEF

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜