简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM