Pair attribute naming in custom configSections
Posted
by fearofawhackplanet
on Stack Overflow
See other posts from Stack Overflow
or by fearofawhackplanet
Published on 2010-05-27T13:58:18Z
Indexed on
2010/05/27
14:01 UTC
Read the original article
Hit count: 149
I'm trying to store a user list in a config file. I've been looking at DictionarySectionHandler
and NameValueSectionHandler
. I'm not too sure what the difference between these two is, but anyway, neither of them do exactly what I'd like.
You can add a custom config section like so:
<configSections>
<section name="userAges" type="System.Configuration.DictionarySectionHandler"/>
</configSections>
<userAges>
<add key="userName1" value="10" />
<add key="userName2" value="52" />
<userAges>
Which is ok, but actually I'd prefer to be able to write:
...
<userAges>
<add user="userName1" age="10" />
<add user="userName2" age="52" />
<userAges>
Which I feel would make the config file clearer to anyone who needed to add/remove users in future.
Is there an easy way to do this?
© Stack Overflow or respective owner