【发布时间】:2016-03-17 15:10:16
【问题描述】:
我的类结构如下:
public class Processor : IRegister
{
public Processor(IRequiredDependency dependency)
{
}
public Type[] ObjectTypes { get; set; }
}
public class TextFile
{}
public class ImageFile
{}
我们为我们的应用程序使用设计时统一配置(基于 XML)。我想为ObjectTypes 注入价值。我有如下 XML 配置:
<type type="SomeNamespace.IRegister, SomeBinary"
mapTo="SomeNamespace.Processor, SomeOtherBinary"
name="MyProcessor">
<property name="ObjectTypes">
<array>
<value value="SomeOtherNameSpace.TextFile, SomeOtherBinary"/>
<value value="SomeOtherNameSpace.ImageFile, SomeOtherBinary"/>
</array>
</property>
</type>
我期待 unity 能够翻译“SomeOtherNameSpace.TextFile, SomeOtherBinary”,它只不过是“FullyQualifiedClassName, AssemblyName”。但我收到以下错误:
TypeConverter 无法从 System.String 转换。
看来我错过了什么。
【问题讨论】:
标签: c# dependency-injection unity-container