In order to realize my ambitions and create a configuration management environment for .NET 2.0 it would be crucial to:
1) Be able to manage big configuration schema’s
2) Have a generic mechanism to add configuration support for configuration settings, with minimal effort.
To meet the first requirement I needed a big schema to get my hands dirty on: Windows Communication Foundation.
The second requirement was a matter of implementation…
Using EntLib’s Configuration Console as a host for the configuration editor gave me a true kick start, but also bound me to an API in which every ‘configuration node’ was defined in more than 100 lines of code, just for the graphical representation.
In EntLib’s Configuration Console a ‘configuration node’ is shown in a treeview and represents a part of the configuration schema you are editing. The ConfigurationNode defines “Configuration properties”, “Validation rules” and allows for registered commands to perform tasks on it.
With around 50 configuration nodes within Wcf configuration schema parts I wanted to support, typing 5000 lines of code just to draw a graphical representation wasn't going to cut it in the 5 days I was able to spend on this demo.
Please keep in mind that this never was a requirements for developing Enterprise Library, I am basically ‘misusing’ a tool that was developed to manage Enterprise Library’s configuration schema.
Writing a generic baseclass for all configuration nodes took about a day’s work. And was defined as follows (slightly simplified)
[TypeDescriptionProvider(typeof(DelegatedTypeDescriptorProvider))]
public abstract class GenericConfigurationNode<TData> : ConfigurationNodeWithAutoName, IDelegatedTypeDesciptorAccessable, ISitedConfigurationNodeSink
{
TData _data;
public GenericConfigurationNode(TData data, string nameProperty)
{
_data = data;
//...
}
public TData TheData
{
get { return _data; }
}
public Dictionary<string, List<Attribute>> AttributesByPropertyName
{
get{return GetAttributesByPropertyName();}
}
protected abstract Dictionary<string, List<Attribute>> GetAttributesByPropertyName();
}
Please note:
1) The type argument allows for a type to be passed that defines the properties that should be edited in the configuration tool (typically a derivement of ConfigurationElement or ConfigurationSection).
2) The virtual method GetAttributesByPropertyName allows a derivement of the generic node to add information to the properties shown in the grid.
3) Deriving from the baseclass was all i needed to create a graphical representation for a configurationnode and now took ~5 lines of code (instead of ~100)
Writing configuration support for Windows Communication Foundation took me an additonal 4 days of work (including some wizards, validation, pretty icons and other nice-to-demo-ables).

<<binaries attached>>