Register | Login

Stacking Code

public interface IBlog { string Dump(Stream consciousness); }

Custom Configuration Sections Made Easy

Monday, 19 September, 2011 @ 7:08 AM < Adam Boddington
Tags: Configuration

I had the opportunity to try out the very solid Configuration Section Designer on the weekend, a Visual Studio extension for putting together custom configuration sections quickly and easily. Anyone who has put together their own configuration section using the older IConfigurationSectionHandler or the newer ConfigurationSection knows it can take a bit of time and some trial and error. With the CSD extension I had a small but non-trivial custom configuration section up and running in under an hour.

Most of the goodness comes from the easy-to-use graphical designer. Define a section, define some elements, define some collections if you need them, and then pull them all together.

Designer

I was able to use inheritance to save myself some repetition with my attributes.

Configuration Element Properties

The configuration section is code generated automagically.

Solution Explorer

A XSD file is also generated for config file intellisense.

App.config

Primitive types are covered. Custom enumurations (including Flags) can be created using the tool itself (code and XSD will be generated), or imported (only XSD will be generated). Any type you like can be imported in the same way.

Configuration Section Explorer

Finally, using the configuration section is easy thanks to a convenience singleton added to the generated code.

for (int index = 0; index < Settings.Instance.Applications.Count; index++)
    AddImageToMenu(Settings.Instance.Applications[index].Image);

I'm very impressed by this extension and I'll definitely be using it again.

There are 0 comments.


Comments

Leave a Comment

Please register or login to leave a comment.


Older
Remove Unversioned Files

Newer
Stuff to Try

Older
Remove Unversioned Files

Newer
Stuff to Try

browse with Pivot


About


Projects

Building Neno


RSS
Recent Posts

Codility Nitrogenium Challenge
OS X Lock
HACT '13
Codility Challenges
Priority Queue


Tags

Architecture (13)
ASP.NET (2)
ASP.NET MVC (13)
Brisbane Flood (1)
Building Neno (38)
C# (4)
Challenges (3)
Collections (1)
Communicator (1)
Concurrency Control (2)
Configuration (1)
CSS (5)
DataAnnotations (2)
Database (1)
DotNetOpenAuth (2)
Entity Framework (1)
FluentNHibernate (2)
Inversion of Control (5)
JavaScript (1)
jQuery (4)
Kata (2)
Linq (7)
Markdown (4)
Mercurial (5)
NHibernate (20)
Ninject (2)
OpenID (3)
OS X (1)
Pivot (6)
PowerShell (8)
Prettify (2)
RSS (1)
Spring (3)
SQL Server (5)
T-SQL (2)
Validation (2)
Vim (1)
Visual Studio (2)
Windows Forms (3)
Windows Service (1)


Archives


Powered by Neno, ASP.NET MVC, NHibernate, and small furry mammals. Copyright 2010 - 2011 Adam Boddington.
Version 1.0 Alpha (d9e7e4b68c07), Build Date Sunday, 30 January, 2011 @ 11:37 AM