简体   繁体   English

如何注入在Windsor注册的MEF [ImportingConstructor]依赖项?

[英]How do I inject MEF [ImportingConstructor] dependencies registered with Windsor?

I'm working on a C#/MVC app that currently uses Windsor as a DI framework, and have just started exploring MEF to make the app more extensible. 我正在开发一个目前使用Windsor作为DI框架的C#/ MVC应用程序,并且刚刚开始探索MEF以使应用程序更具可扩展性。 It's been working beautifully, right up till the point where my plugins need to have dependencies satisfied. 它一直工作得非常好,直到我的插件需要满足依赖关系的程度。

How can I inject Windsor managed dependencies into a class that is imported by MEF, preferably with [ImportingConstructor]? 如何将Windsor托管依赖项注入由MEF导入的类中,最好使用[ImportingConstructor]?

I've tried extending ContainerAdapterBase from MefContrib but can't figure out how to get it to work with [ImportingConstructor]. 我已经尝试从MefContrib扩展ContainerAdapterBase,但无法弄清楚如何使用[ImportingConstructor]。 Also, using MEF for IoC is not an option. 此外,使用MEF for IoC不是一种选择。

Thanks! 谢谢!

Update: My current solution is to write a simple 'DSL', managed by Windsor, that provides all the functionality required by plug-ins, and then manually inject that whenever MEF passes me a plug-in instance. 更新:我目前的解决方案是编写一个由Windsor管理的简单“DSL”,它提供插件所需的所有功能,然后在MEF通过插件实例时手动注入。 Possibly a bit nasty but it works, it also means I don't have to do any service location from plugins, and also provides a nice boundary around what a plugin is 'allowed' to do. 可能有点讨厌,但它的工作原理,这也意味着我不必从插件中做任何服务位置,并且还提供了一个关于插件“允许”做什么的好边界。

Any thoughts on this approach would be greatly appreciated. 对此方法的任何想法将不胜感激。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM