Issue Details (XML | Word | Printable)

Key: SPRNET-58
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Mark Pollack
Reporter: Mark Pollack
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring.NET

multi-value support in NameValueCollection

Created: 27/Mar/05 03:54 PM   Updated: 03/Dec/06 11:35 AM   Resolved: 17/Nov/06 02:37 PM
Component/s: Spring-NET-CORE
Affects Version/s: 1.0.2
Fix Version/s: 1.1 P3

Time Tracking:
Not Specified


 Description  « Hide
Add an optional attribute to the name-value element; multi-value. This would interpret a comma separated list as multiple additions to the NameValueCollection. So the code

Code:

<property name="nvProp">
  <name-values multi-value="true">
    <add key="myKey" value="foo,qwerty,asdf"/>
  </name-values>
</property>
 


would result in

string[] ss = obj1.nvProp.GetValues("myKey");

ss[0] = [foo]
ss[1] = [qwerty]
ss[2] = [asdf]



Aleksandar Seovic added a comment - 27/Mar/05 10:44 PM
I don't think this is the best way to do it. What happens if you want some entries to have multiple values and some single? I'd rather move multi-value attribute to entry element, or better yet, simply use "values" instead of "value" to specify that entry has multiple values.

Rick Evans added a comment - 20/Jul/05 04:53 AM
Moved to 1.1 while we figure out how to support this.

Rick Evans added a comment - 30/Jul/05 08:42 AM
This forum posting describes a possible configuration style.

http://forum.springframework.net/viewtopic.php?t=71

Mark Pollack added a comment - 08/Apr/06 07:13 PM
Hi,

Following up on Aleks suggestion..

<property name="nvProp">
  <name-values>
    <add key="myMultiValueKey" values="foo,qwerty,asdf"/>
    <add key="mysingleValueKey" value="tomf"/>
    <add key="myMultiValueKeyWithDelim" values="wallace,grommit:charliebrown,snoopy" delimiter=":"/>
  </name-values>
</property>

string[] ss = obj1.nvProp.GetValues("myMultiValueKey");
ss[0] = [foo]
ss[1] = [qwerty]
ss[2] = [asdf]

string[] ss = obj1.nvProp.GetValues("myMultiValueKeyWithDelim");
ss[0] = [wallace,grommit]
ss[1] = [charliebrown,snoopy]





Aleksandar Seovic added a comment - 17/Nov/06 02:37 PM
I actually ended up with a slightly different schema: there is no 'values' attribute, but if 'delimiters' attribute is specified value will be treated as a multi-valued, delimiter-separated string.

    <property name="props">
      <name-values>
        <add key="name" value="Twain, Mark"/>
        <add key="foo" value="bar1,bar2,bar3" delimiters=","/>
        <add key="days" value="monday,tuesday.wednesday:thursday'friday!saturday|sunday" delimiters=",.:'!|"/>
      </name-values>
    </property>

First value in the example above will be treated as a single-valued string, "Twain, Mark", while the other two will be split up using specified delimiters and treated as multi-valued strings.