【发布时间】:2013-07-24 18:09:41
【问题描述】:
我在命名空间 Device.Control 中有一个枚举...
public enum State {
IN_PROGRESS, SUSPENDED, HALTED, FINISHED
}
我有一堂课……
public class CustomStateManager {
public IList<State> ManagingStates { get; set; }
}
这是我用于 spring.net 的配置 XML...
<object id="MyStateManager" type="CustomStateManager">
<property name="ManagingStates">
<list>
<value>SUSPENDED</value>
<value>HALTED</value>
</list>
</property>
</object>
在构建并尝试注入 MyStateManager 对象后,Spring.NET 抱怨它无法设置对象的ManagingStates 属性。我收到此错误...
创建在“文件”中定义的名称为“MyStateManager”的对象时出错 [Spring.xml] 第 3 行':设置属性值时出错: PropertyAccessExceptionsException(1 个错误);嵌套的 PropertyAccessExceptions 是:[Spring.Core.TypeMismatchException: 无法转换类型 [System.Collections.ArrayList] 的属性值 到所需类型 [System.Collections.Generic.IList
1[[SandboxConsole.Device.Control.ApplicationEnumerations+State, SandboxConsole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]] for property 'ManagingStates'., Inner Exception: Spring.Core.TypeMismatchException: Cannot convert property value of type [System.Collections.ArrayList] to required type [System.Collections.Generic.IList1[[SandboxConsole.Device.Control.ApplicationEnumerations+State, SandboxConsole,版本=1.0.0.0,文化=中性, PublicKeyToken=null]]] 用于属性 'ManagingStates'...
我对 Spring.NET 有点陌生,除了无法将 ArrayList 注入 IList 属性之外,我无法弄清楚这里的问题是什么。 是否可以在值是枚举类型的配置中创建列表?如果有,怎么做?
【问题讨论】:
标签: c# enums spring.net