Home  /  Questions  /  Question

88   96.5
Aug 28, 2012

How to write a Custom Configuration Collection Section with Composite Pattern

 I want to write Composite Pattern to web.config like below

 <membership defaultProvider="TestSqlMembershipProvider">
           <add name="TestSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"      
                    connectionStringName="TestConsumerEndPoint" enablePasswordRetrieval="false" enablePasswordReset="true"
                     requiresQuestionAndAnswer="false" applicationName="Nda" requiresUniqueEmail="true" passwordFormat="Hashed"
                     maxInvalidPasswordAttempts="10" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"

Also I want to create this object using the Abstract Factory pattern.
Any idea how to go about this?


578   99.9
Sep 05, 2012

I'm not sure what you are asking, but I have built an open source application called MvcInstaller that programmatically creates the Membership sections in the web.config.  You can see a video of the application that uses this here, http://www.mvccentral.net/s/45.

You can also get the code at my github.com repository here: https://github.com/kahanu/MvcInstaller.

Here's a quick look at the code: https://github.com/kahanu/MvcInstaller/blob/master/MvcInstallerV3/ConfigurationFactory.cs

I hope this helps.

King Wilder
Hi King, Thanks for your answer. I want to create above Membership xml with composite pattern and after that i want to create my custom Membership Class by using that Xml . --- Volkan Genç  Sep 06, 2012
Volkan, sorry for the long delay in the response, but I'm sure you must have figured it out by now. Are you talking about Serialization and De-serialization from the xml to an unknown class? You can do this but you must have an existing class that represents the Xml so the serializer will know how to deserialize the xml to a class. I hope this helps. --- King Wilder  Oct 23, 2012