Array input property using Spring.Net

I use the Spring.Net IoC container and can use it to input properties of type IList and even IList<T> , but I'm a bit of a dead end on how to introduce thats property of type string[] .

It seems that there is no <array> element defined in XSD, and using <list> <value> </list> does not work either.

If anyone could post xml, I would need to inject using an array for a property that would be very appreciated

+4
source share
1 answer

As mentioned here in the documentation , you can enter a string array as a comma-separated string (not sure if the syntax is designed to speed up the actual commas in strings, if necessary). In other words, your config will look something like this:

 <object id="MyObject" type="Blah.SomeClass, Blah" > <property name="StringArrayProperty" value="abc,def,ghi" /> </object> 

Manually building string[] with the following syntax also works if you need something more complex (for example, if you are viewing individual values ​​from some other link, rather than hard-coding them):

 <object id="TestStrArr" type="string[]" > <constructor-arg value="3" /> <property name="[0]" value="qwe" /> <property name="[1]" value="asd" /> <property name="[2]" value="zxc" /> </object> <object id="MyObject" type="Blah.SomeClass, Blah" > <property name="StringArrayProperty" ref="TestStrArr" /> </object> 
+7
source

All Articles