Saturday, June 24, 2006 3:52 PM Olaf Conijn

CoMan Proof of Concept #1: Configuring WCF

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>>

Filed under: , ,

# “Enterprise Library Extensions” becomes “.NET Configuration Manager”

Saturday, June 24, 2006 7:19 AM by ^(?:[^$]*)$ --Matches everything, captures nothing

After having my share of success with developing the “Enterprise Library Extensions”, I started thinking...

# CoMan Proof of Concept #2: full configuration support for System.Web

Saturday, June 24, 2006 8:44 AM by ^(?:[^$]*)$ --Matches everything, captures nothing

Before starting the development of a&amp;nbsp;general purpose&amp;nbsp;configuration management environment,...

# re: CoMan Proof of Concept #1: Configuring WCF

Saturday, June 24, 2006 1:48 PM by Erwyn van der Meer

Olaf, which version of WCF are you using? I have WinFX Beta 2 installed and I get a exception when adding a WCF Configuration using the tool: "Could not load type System.ServiceModel.Configuration.XmlFormatterSection."

According to http://blogs.msdn.com/madhuponduru/attachment/605194.ashx this class has been removed in Beta 2.

# re: CoMan Proof of Concept #1: Configuring WCF

Monday, June 26, 2006 6:44 AM by Olaf Conijn

Erwyn, If I'm correct, WinFx runtime beta 2 ships with WCF version 3.0.0.0.

I tried this on my box using WCF version 3 and didnt get an exception.

Is there someone else that can confirm this bahaviour? or point out a flaw in my reasoning?

# re: CoMan Proof of Concept #1: Configuring WCF

Monday, June 26, 2006 12:31 PM by Erwyn van der Meer

Olaf, I believe the WCF assembly versions have been fixed to 3.0.0.0 even before Beta 2. You might want to check the file version of System.ServiceModel.dll. For Beta 2 it's 3.0.3906.22.

# re: CoMan Proof of Concept #1: Configuring WCF

Monday, June 26, 2006 1:17 PM by Olaf Conijn

even though it has been some time since I installed wcf... My file-version of System.ServiceModel is: 3.0.50727.358 (by right-clicking the assembly in c:\windows\assembly).

# re: CoMan Proof of Concept #1: Configuring WCF

Monday, June 26, 2006 2:39 PM by Erwyn van der Meer

Olaf, your version number indicates you have the  February 2006 CTP installed. The Beta 2 version is newer. See http://www.microsoft.com/downloads/details.aspx?FamilyID=4a96661c-05fd-430c-bb52-2ba86f02f595&displaylang=en.