I’m learning how to use the Prism Navigation API and it requires registering your Views (or ViewModels if using ViewModel-first) with the Unity container in the following manner:
Container.RegisterType<object, HomeView>("HomeView");
See this blog post and the MSDN Documentation. The examples I have seen have registered these types in the Bootstrapper class via the ConfigureContainer() method. But some examples register types in the Module classes. My question is: does it matter where you register these types with the container?
My gut feeling is that registration in the Bootstrapper ConfigureContainer() method will make the registered types available to all Modules while registration in the Module classes will mean those types are only registered in that Module.
Short answer: No it doesn’t mather where you register.
It would be only logical to register instances appropiate in which library they excist. Unity is also a little different.
Example 1:
Lets say you have ModuleA and ModuleB and you would have an interface in infrastructure. You register this interface to an implementation in ModuleA. You then resolve this instance in moduleB. It would work because you have it configured in moduleA. If you havent, then example 2 is for you.
Example 2:
Lets say you have a unregistered type of ClassA. You did not configure this in the
bootstrapperormoduleand you call a resolve on this class. Unity does this automaticly for you and resolves it and it even resolves dependecies if he can find them. There might be one exception. I’m not sure about interfaces, I believe if it is not registered to a concrete implementation it cant resolve it.