views:

203

answers:

1

I am trying to use Spring.NET with a C# application to populate a parameter array (params keyword) constructor argument that is of a complex Type (call it SecretCode, which happens to be an enumerated type.)

Can someone help point me to the documentation to configure the XML file to do this?

For reference, here are relevant code snippets:

public class MyValueSet<T> where T: struct
{
  public MyValueSet(params T[] values) {...}
} 

public class DerivedClass : MyValueSet<SecretCode> {...}

public enum SecretCode {...}

The hard-coded code I am trying replace with the Spring.NET configuration file is (close enough to) this:

var something = new DerivedClass(SecretCode.One, SecretCode.Two, SecretCode.Fifty-Two);

Thoughts?

+1  A: 

I posted the question in order to share the answer I came up with, and to see if anyone who knows Spring.NET more thoroughly had a better answer.

The configuration I ended up with is this:

<object id="myobject" type="DerivedClass, Assembly.Containing.The.DerivedClass">
  <constructor-arg name="values">
    <list element-type="SecretCode, Assembly.Containing.The.SecretCode.Enumeration">
      <value>One</value>
      <value>Two</value>
      <value>Fifty-Two</value>
    </list>
  </constructor-arg>
</object>
JohnKeller
This is the correct configuration imho. I don't think there is no other way.
BennyM