Daedalus
Daedalus

Reputation: 61

IoC Container accessibility

I'm wondering if the IoC Container should be referenced only by the class that instantiates and configures it, or if it can be injected into other classes, VMs and VML for example. I'm asking because i saw many people pass it through the ViewModelLocator's construtctor and use it from there.

Is this approach acceptable or to be avoided?

Thank you very much.

Upvotes: 0

Views: 160

Answers (1)

Krzysztof Kozmic
Krzysztof Kozmic

Reputation: 27384

You are correct - passing container is Doing it Wrong since it goes against the whole Inversion of Control idea. Here's a few links for you:

Here's how I use IoC containers (and part 2)

I also recommend checking out Windsor's documentation, especially Concepts section which is quite universal (and will be useful to you even if you're not using Windsor).

Upvotes: 1

Related Questions