0

It was very handy with Autofac on dependency injection.

Recently I changed project where lightinject and unitycontainer uses. Here I am able to register a list of services with a name, but I'm unable to resolve by a name.

I tried to get it as IEnumerable. I'm getting all, but not the name I registered. So I'm unable to distinguish them.

What am I missing here?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Binesh Nambiar C
  • 152
  • 1
  • 2
  • 9
  • To make the question more clear, you might want to add a [MRE](https://stackoverflow.com/help/minimal-reproducible-example). – Steven Jul 09 '20 at 14:18
  • @Steven: In Autofac We could call "container.ResolveNamed("online");" https://autofaccn.readthedocs.io/en/latest/advanced/keyed-services.html Even in lightinject i could register registrations.RegisterInstance(resultsWebEnvironmentSettings, "ResultsWebEnvironmentSettingsBase"); But not seeing a resolve for the same(Even could register with name – Binesh Nambiar C Jul 09 '20 at 14:45

1 Answers1

1

https://www.tutorialsteacher.com/ioc/property-injection-using-unity-container see the section Named Mapping

 public class Service {
     [Dependency("AName")]
     public IDependency Dependency {get;set;}
 }
ddfra
  • 2,413
  • 14
  • 24