Internal IoC - Config File?

Sep 15, 2011 at 9:58 PM

Before version 2 of Catel, it was suggested that a Unity section be added to the App.Config of a test project to remap services such as IMessageService to Test versions of the services.  Now that Catel uses its own IoC implementation, is there still a way to remap the services in app.config?  If not, what is the recommended way to do this in a test project?

 

Sep 15, 2011 at 11:42 PM

Now you have all the freedom you want. So, if you want to use Unity, go ahead and keep using Unity like you were used to. Just don't forget that you need to register external containers before using any services:

Catel.IoC.ServiceLocator.Instance.RegisterExternalContainer(myUnityContainerWithConfigurations);

Sep 16, 2011 at 2:04 AM

Thanks, Geert.  I was kind of hoping to just use the internal container to keep it simple, but it's easy enough to register Unity. 

Sep 16, 2011 at 8:39 AM

You are welcome. The reason we did this is we decided to create a very smart ServiceLocator (read more about it here), but not create a new IoC container type. Unity already provides configuration, MEF is very powerful too, so we thought: if we could just create a provider with basic runtime behavior, that can simply use other external containers without references.

And that's what we did. In version 2.2, we will add Ninject to the list of supported external IoC containers. And, if other people also request support for other containers, they just have to let us know :)