Using StructureMap to Configure Prism
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. 开发者_Go百科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?
Here you may found what you need: http://code.google.com/p/compositewpf-structuremapextensions/
This is definitely doable. You need to do 2 things, essentially:
- Create a new bootstrapper (StructureMapBootstrapper).
- 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.
精彩评论