.Net Configuration: How to use tag values instead of attributes



I'm writing a custom configuration section. I'd like the xml to look something like this:



<MainSettings>
<UpperCase>True</UpperCase>
<PopupClient>False</PopupClient>
<Language>en-GB</Language>
</MainSettings>


How do I code the ConfigurationSection and ConfigurationElement derived classes to produce this?


I know how to produce it in this form:



<MainSettings>
<UpperCase value="True" />
<PopupClient value="False" />
<Language value="en-GB" />
<MainSettings>


However, this would produce somewhat unpleasant to use model code in the form:



mainSettings.UpperCase.Value = true;


instead of simply:



mainSettings.UpperCase = true;


I'm also aware of the xml form:



<MainSettings UpperCase="True"
PopupClient="False"
Language="en-GB" />


which can be married up to the second code form.


So, is it possible to match up the first or second xml forms with the second code form?


No comments:

Post a Comment