Sladescross's Blog

Blogging about Sharepoint related stuff

.NET Custom Configuration Settings December 25, 2009

Filed under: .NET,Configuration,Custom,Settings — sladescross @ 11:53 pm

    <sectionGroup name=”userSettings”
        type=”System.Configuration.UserSettingsGroup, System,
              Version=, Culture=neutral,
      <section name=”MSDNSampleSettings.My.MySettings”
        type=”System.Configuration.ClientSettingsSection, System,
             Version=, Culture=neutral,
        requirePermission=”false” />
      <setting name=”Setting” serializeAs=”String”>

A few things in the above code deserve special mention:

  • The CollectionType property specifies AddRemoveClearMap, which is what gives your collection the standard behavior of an element collection in the configuration file.
  • If you specify a key, you’ll need to override GetElementKey to return the value of the appropriate property. Note that your key property doesn’t have to be a string. I could have used my Identifier property as the key.
  • Some of the methods provide a familiar name to access corresponding base class operations. For example, the Clear method executes BaseClear.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 63 other followers