Registering Named instances in Funq container

I’ve noticed that there are a couple of overloads/variations of Container.Register that can take a named instance and was wondering if there’s any specific reason that all of the overloads (e.g. RegisterAutoWired<T>(), RegisterAutoWiredAs<T, TAs>(), RegisterAutoWiredType() etc) haven’t been implemented?

I was looking for something akin to Autowiring Generic Type Definitions from the wiki but being able to name each instance and noticed there wasn’t support for that. I think I could hack it together as an extension method but as part of my investigation I’ve implemented it in a fork of ServiceStack - is this worth creating a PR for or do you think it’s something that’s better implemented as an extension method in individual projects?

The support for Named Instances was already in Funq but it’s not something we use since it doesn’t follow the recommended use-case of having dependencies injected by Type. The RegisterAutoWired* API’s are our own extensions we’ve added on Funq and we don’t included named instance overloads since we don’t recommend its usage. But if it’s a small/non-disruptive change we can accept the PR to add it.

Cool, makes sense. TBH I’m not normally a fan of named instances either but makes sense in this case.

I’ll open a PR shortly and you can accept/reject depending on what you think.

Edit: PR:

Yep looks good, merged :smile: