Unity Resolve Multiple Classes

前端 未结 2 1503
萌比男神i
萌比男神i 2021-02-14 16:34

How do I get microsoft unity to \'construct\' a list of classes for a given interface type.

Very Simple example:

  List list          


        
2条回答
  •  青春惊慌失措
    2021-02-14 17:18

    If you are using Unity 2 you can use ResolveAll

    Container.RegisterType("Florida");
    Container.RegisterType("NewYork");
    Container.RegisterType("Alaska");
    
    IEnumerable infos = Container.ResolveAll();
    

    You have to give a name to every registration because ResolveAll will only return named registrations.

提交回复
热议问题