Hi,
Based on my understanding, you can also declare in the configuration file if you want to pass an specific value to a constructor parameter. For example, I believe you can do this by using the <constructor> , <param> and <value> XML elements. You can find more information about this in the following sections of the Unity documentation:
On the other hand, besides registering the types in the container using a configuration file, you should also be able to register them in the same way that you do in Prism. For example, I tried commenting the registration line of the IVehicleRepository interface from the configuration file and registering the type manually in the Global.asax.cs 's InitializeDependencyInjectionContainer method:
Either of the two approaches should be useful to register the corresponding types as you need, but the first approach seems to be the cleaner one.
I hope this helps,
Damian Cherubini
http://blogs.southworks.net/dcherubini
Based on my understanding, you can also declare in the configuration file if you want to pass an specific value to a constructor parameter. For example, I believe you can do this by using the <constructor> , <param> and <value> XML elements. You can find more information about this in the following sections of the Unity documentation:
On the other hand, besides registering the types in the container using a configuration file, you should also be able to register them in the same way that you do in Prism. For example, I tried commenting the registration line of the IVehicleRepository interface from the configuration file and registering the type manually in the Global.asax.cs 's InitializeDependencyInjectionContainer method:
private static void InitializeDependencyInjectionContainer()
{
container = new UnityContainerFactory().CreateConfiguredContainer();
var serviceLocator = new UnityServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => serviceLocator);
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
// We register the type manually.
container.RegisterType<IVehicleRepository, VehicleRepository>(new UnityHttpContextPerRequestLifetimeManager());
}
The result was that both the type registered manually and the types registered by the configuration file were correctly registered in the container.Either of the two approaches should be useful to register the corresponding types as you need, but the first approach seems to be the cleaner one.
I hope this helps,
Damian Cherubini
http://blogs.southworks.net/dcherubini