Can Windsor cooperate with another IoC container?

江枫思渺然 提交于 2019-12-23 09:36:26

问题


In the core of our application, we use Castle Windsor to manage our dependencies. We'll be loading plugins from third parties which may be using their own IoC containers. We'd like them to be able to receive dependencies from the core, e.g. through constructor injection of the core's services, but also receive dependencies from their own IoC container.

It seems like if they supplied a service provider interface, Windsor could use it to resolve unknown dependencies, ignoring the results (since the lifetime of these components is someone else's business) and keep on trucking.

But I am also sure there are some great subtleties that come up when you attempt something like this.


回答1:


That's not necessary. If you enable those plugins to use Constructor Injection to get the appropriate services from your host application, Castle Windsor can wire up the PlugIn correctly. PlugIns simply use Constructor Injection as a way to statically declare a dependency, so as long as Windsor can resolve the dependency, the PlugIn will receive it.

What happens inside of each PlugIn (including use of other containers) is of no concern of the host application.



来源:https://stackoverflow.com/questions/5987841/can-windsor-cooperate-with-another-ioc-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!