Named registration and resolution in SimpleInjector

Apr 21, 2013 at 11:44 AM
Hi, i'm in the process of moving away from Unity DI and i would like to replace it with Simple Injector.

In our framework we made heavy usage of named registration
because it nicely fits our requirements (the class invoking the resolve method is always the same but the actual resolution is decided by a string inserted by the final user in a property grid)

Is it possible to have a similar name-driven resolution of types in SimpleInjector?
IIUC Simple-Injector docs what we need is a kind of Context Based Injection where our context is simply given by a string.

What is the best way to usage Simple Injector in this scenario?

Thank you in advance,
Apr 21, 2013 at 8:21 PM
Resolving instances by a key is a feature that is deliberately left out of the Simple Injector. This documentation page explains why, and gives a few examples of how to add named registration to Simple Injector.

Note that Context Based injection is almost certainly NOT what you're looking for. Please take a look at the examples in the references page and let me know when this doesn't work for you. There's little you cannot do with Simple Injector. And the few things you cannot do, you shouldn't probably be doing anyway ;-)
Marked as answer by dot_NET_Junkie on 11/5/2013 at 7:39 AM
Apr 22, 2013 at 11:38 AM
Thank you very much for your answer, you're right, the "how to" page gave me exactly what i was searching for,

I don't know how i missed it in the first place, great stuff.