Does he need his own configuration section? Personally, I rarely find it necessary to go beyond the simple settings in the project properties. This is how I did it in a project where I wanted to use a list of sources that were allowed and forbidden. The object that I wanted to save in the configuration (in my case, user.config, but the principle is the same for app.config) is a simple C # object (it implements an interface not associated with this discussion, that's all).
So to make it easier, I created a collection class for my object. This simplifies setup. Here's the class as a whole:
// This is mainly declared to ease use as a User Setting public class SpellSourceCollection : List<SpellSource> { public SpellSourceCollection() : base() { } public SpellSourceCollection(IEnumerable<SpellSource> ListToCopy) : this() { this.AddRange(ListToCopy); } }
Remember that SpellSource has nothing special. Now, in the project settings, I can assign Type as my collection object.

You may need to βviewβ the correct user object. However, once this is done, reading from app.config (or user.config) is a breeze. Here's what the configuration file looks like (a bit short).
<setting name="Sources" serializeAs="Xml"> <value> <ArrayOfSpellSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SpellSource> <Source>PFRPG Advanced Player Guide</Source> <Allowed>true</Allowed> <BackgroundColor>White</BackgroundColor> </SpellSource> <SpellSource> <Source>PFRPG Core</Source> <Allowed>true</Allowed> <BackgroundColor>White</BackgroundColor> </SpellSource> <SpellSource> <Source>Rival Guide</Source> <Allowed>false</Allowed> <BackgroundColor>White</BackgroundColor> </SpellSource> <SpellSource> <Source>Ultimate Combat</Source> <Allowed>true</Allowed> <BackgroundColor>White</BackgroundColor> </SpellSource> <SpellSource> <Source>Ultimate Magic</Source> <Allowed>true</Allowed> <BackgroundColor>Cyan</BackgroundColor> </SpellSource> </ArrayOfSpellSource> </value> </setting>
Getting a property is just a question.
SpellSourceCollection settingsSources = Properties.Settings.Default.Sources; // do stuff or even later in your project, you can save this user setting Properties.Settings.Default.Sources = settingsSources; Properties.Settings.Default.Save();
You can apply this to your project in a similar way. Only slightly complex bits declare a collection object and create a parameter in the project properties.
source share