Is it best or bad with DI?

Feb 10, 2012 at 3:31 AM
Edited Feb 10, 2012 at 4:58 PM


If I have a number of service shall i register at Globle scope of local scope? Global.asax or Controller


container.RegisterType<IEventRepository1, EventRepository1>(new ContainerControlledLifetimeManager());

container.RegisterType<IEventRepository2, EventRepository2>(new ContainerControlledLifetimeManager());

container.RegisterType<IEventRepository3, EventRepository3>(new ContainerControlledLifetimeManager());

container.RegisterType<IEventRepository4, EventRepository4>(new ContainerControlledLifetimeManager());

container.RegisterType<IEventRepository5, EventRepository5>(new ContainerControlledLifetimeManager());

container.RegisterType<IEventRepository6, EventRepository6>(new ContainerControlledLifetimeManager());



Feb 10, 2012 at 7:48 PM


Mileage Stats uses Unity for dependency injection. And maps interfaces to concrete classes and also determines the lifetime of each mapping in the unity.config file in the web application. This container is initialized in global.asax and as there only one container, so far I didn't find a difference in registering types from one scope or the other.

Additionally you could more information about dependency injection in the following links:


Agustin Adami

Feb 11, 2012 at 5:56 AM