使用 StructureMap 配置 Prism

发布于 2024-08-13 01:08:09 字数 344 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡绿茶香 2024-08-20 01:08:09

这绝对是可行的。您本质上需要做两件事:

  1. 创建一个新的引导程序(StructureMapBootstrapper)。
  2. 创建利用 StructureMap 的 IContainerFacade 实现。

实际上没有使用任何 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:

  1. Create a new bootstrapper (StructureMapBootstrapper).
  2. Create an implementation of IContainerFacade that utilizes StructureMap.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文