Is it best or bad with DI?

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

Hi,

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

e.g

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());

 

 

Developer
Feb 10, 2012 at 8:48 PM

Hi,

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:

Regards,

Agustin Adami
http://blogs.southworks.net/aadami


Feb 11, 2012 at 6:56 AM

Thanks.