views:

262

answers:

2

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?

+2  A: 

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.

Anderson Imes
Thanks! Will have a look at the Ninject samples.
stiank81
+3  A: 

Here you may found what you need: http://code.google.com/p/compositewpf-structuremapextensions/

Andres