开发者

How to set enum Type indexer in Spring.NET configuration xml?

开发者 https://www.devze.com 2022-12-10 02:16 出处:网络
I have this code: public enum StateId { NotSet = 0, AL, ..., WY } public class EnumBasedArray<I,V>:IEnumerable<V>

I have this code:

public enum StateId { NotSet = 0, AL, ..., WY }

public class EnumBasedArray<I,V>:IEnumerable<V> 
{
  public V this[I index]
  { 
    get { return _data[index]; }
    set { _data[index] = value; }
  }
  // other code to manage values internall开发者_如何转开发y
}

public class AnotherObject { ... }

public class ArrayOfAnotherObjectByStateId:EnumBasedArray<StateId, AnotherObject> {}

Where I have trouble is telling Spring.NET the values of each item in the StateId-indexed array via the configuration XML file.

In code, I'd write something like:

var x = new ArrayOfAnotherObjectByStateId();
x[StateId.AZ] = new AnotherObject(...);
x[StateId.CA] = new AnotherObject(...);

How do I do this in the Spring xml? The closest I've come is:

<object id="matrix" type="ArrayOfAnotherObjectByStateId">
   <property name="[AZ]" ref="AZ.Matrix">
</object>

<object id="AZ.Matrix" type="AnotherObject" />

which gives me the error "Error creating context 'spring.root': 'AZ' node cannot be resolved for the specified context"


<object id="matrix" type="ArrayOfAnotherObjectByStateId">
   <property name="[T(NamespaceYouUse.StateId).AZ]" ref="AZ.Matrix">
</object>

Tested with Spring.NET 1.2

0

精彩评论

暂无评论...
验证码 换一张
取 消