Binesh Nambiar C
Binesh Nambiar C

Reputation: 162

Dependency injection(Autofac equivalent for resolvebyname or key)

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?

Upvotes: 0

Views: 335

Answers (1)

ddfra
ddfra

Reputation: 2565

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;}
 }

Upvotes: 1

Related Questions