Question

What I'm getting at, logically, is something like this:

<object id="foobarList" type="string[]">
    <list>
        <value>foo</value>
        <value>bar</value>
    </list>
</object>

Any ideas?

Was it helpful?

Solution 2

Actually, the related questions list provided the answer. Thanks anyway.

Property Inject an Array with Spring.Net

OTHER TIPS

It's not quite a string[], but could you use:

<object id="foobarList" type="System.Collections.ArrayList">
    <constructor-arg>
        <list>
            <value>foo</value>
            <value>bar</value>
        </list>
    </constructor-arg>
</object>

There is a way to create a string[] as a Spring.Net object but it is remarkably painful (create a string object (hard in itself), then create a Type object using its GetType method, then pass that into the ArrayList.GetArray method to get your string[] object.

They do have some recent improvements in this area but not in a stable release yet. I'd consider writing a little factory class to make this easier, or changing the class that expects a string[] to something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top