how to implement IOC without a global static service (non-service locator solution)?

Posted by Michel on Stack Overflow See other posts from Stack Overflow or by Michel
Published on 2010-06-09T14:08:25Z Indexed on 2010/06/10 12:03 UTC
Read the original article Hit count: 341

Hi,

we want to use Unity for IOC. All i've seen is the implementation that there is one global static service which holds a reference to the Unity container, which registers all interface/class combinations and every class asks that object: give me an implementation for Ithis or IThat.

Frequently i see a response that this pattern is not good because it leads to a dependency from ALL classes to this service.

But what i don't see often, is: what is the alternative way?

Michel

EDIT: found out that the global static service is called the service locator, added that to the title.

© Stack Overflow or respective owner

Related posts about c#

Related posts about inversion-of-control