使用 StructureMap 配置 Prism
我正在使用 Prism 和 Prism 附带的 Unity IoC 容器。但是,如果可行的话,我想使用不同的 IoC 容器。所以;是吗?我最好使用 StructureMap。请注意,我还不熟悉 StructureMap,但根据一些建议,我想尝试一下。
问题实际上在于 Prism 与其 Unity 容器的耦合有多紧密。 UnityBootstrapper 附带了已使用 EventAggregator 等 Prism 内容设置的 IoC 容器。但是 StructureMap 中是否有类似的 Bootstrapper 我可以使用 - 在其中配置所需的 Prism 类?
这是人们建议做的事情,还是我最好坚持使用 Unity?有什么缺点和优点?
I'm using Prism and the Unity IoC container that comes along with Prism. However, I'd like to use a different IoC container if that's doable. So; is it? Preferrably I'd like to use StructureMap. Note that I'm not yet familiar with StructureMap, but based on several recommendations I'd like to give it a try.
The question is really how tightly Prism is coupled to its Unity container. There is the UnityBootstrapper which comes with both the IoC container already set up with the Prism stuff like the EventAggregator. But is there a similar Bootstrapper in StructureMap I can use - configuring the required Prism classes in it?
Is this something one would recommend doing, or am I better of sticking to Unity? What's the downsides and upsides?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里您可能会找到您需要的东西:
http://code.google.com/p/compositewpf-structuralmapextensions/
Here you may found what you need:
http://code.google.com/p/compositewpf-structuremapextensions/
这绝对是可行的。您本质上需要做两件事:
实际上没有使用任何 Unity 特定的功能。它被设计成可更换的。以下是 Ninject 替换的示例:
http://code.google.com /p/ninject-contrib/source/browse/trunk/CompositeWpf/NinjectContrib.CompositeWpf/
这应该是一个很好的替代模型。
This is definitely doable. You need to do 2 things, essentially:
There really aren't any Unity-Specific features being used. It's designed to be replaceable. Here's an example of a Ninject replacement:
http://code.google.com/p/ninject-contrib/source/browse/trunk/CompositeWpf/NinjectContrib.CompositeWpf/
That ought to be a good model for your replacement.