C# Unity 2.0 System.Collections.Generic.List
使用Unity 2.0 xml文件,我试图填充一个包含通用列表的对象。根据Unity配置模式,仅支持数组元素。是否有人尝试过使用unity填充通用列表?您可以在构造函数或setter中解决此限制:C# Unity 2.0 System.Collections.Generic.List,c#,.net,unity-container,aggregation,unity2.0,C#,.net,Unity Container,Aggregation,Unity2.0,使用Unity 2.0 xml文件,我试图填充一个包含通用列表的对象。根据Unity配置模式,仅支持数组元素。是否有人尝试过使用unity填充通用列表?您可以在构造函数或setter中解决此限制: public class MyService : IMyService { List<IMyDependency> _myDeps; [Dependency] public IMyDependency[] Deps { set {
public class MyService : IMyService {
List<IMyDependency> _myDeps;
[Dependency]
public IMyDependency[] Deps {
set {
_myDeps = new List<IMyDependency>(Deps);
}
}
...
}
如果你不能改变你的类,你仍然可以使用工厂