We're wondering what the best practise for registering types in a IoC-Container is.
What would be arguments for and against the following principles:
UnityConfig.cs
) where all types of the whole solution are registeredUnityConfig.cs
fileUnityConfig.cs
fileWhat's your stance in this?
Thanks in advance for your opinions and arguments
my Answer
Principle 2: A IoC container configuration class per executing assembly
Every executing assembly has their own UnityConfig.cs file
Only the needed types of this assembly are registered in the respective UnityConfig.cs file
The reason being, Dependencies are or should be injected at the run-time, so the responsibility of configuring what to inject should live at the top level component/executable, ie in mvc/web-api/wcf/exe.
Also with this approach each project can differ in DI tool, config etc etc.