While I have no doubt that this thing can be done by either using the Config Application Block from the Enterprise Library or by implementing a config section handler (as suggested in the two replies I got for my initial question), here is how I did it w/o adding any new implementation or application block to my project. Just in case someone else out there is trying to solve it right now. The app.config file looks like this:
<configuration> <configSections> <sectionGroup name="customGroup"> <sectionGroup name="customSection"> <section name="cfgSet1" type="System.Configuration.NameValueSectionHandler"/> <section name="cfgSet2" type="System.Configuration.NameValueSectionHandler"/> </sectionGroup> </sectionGroup> </configSections> <appSettings> <add key="CustomConfigSetCounter" value="2" /> </appSettings> <customGroup> <customSection> <cfgSet1> <add key="Param_1" value="Val_11"/> <add key="Param_2" value="Val_12"/> <add key="Param_3" value="Val_13"/> </cfgSet1> <cfgSet2> <add key="Param_1" value="Val_21"/> <add key="Param_2" value="Val_22"/> <add key="Param_3" value="Val_23"/> </cfgSet2> </customSection> </customGroup> </configuration> The code to access it looks like this: UInt32 nConfigSetCounter = Convert::ToUInt32( ConfigurationSettings::AppSettings->Get( S"CustomConfigSetCounter" ) ); for( UInt32 i=1; i<=nConfigSetCounter; i++ ) { Object *pTempObj = ConfigurationSettings::GetConfig( String::Format( S"customGroup/customSection/cfgSet{0}", i.ToString() ) ); NameValueCollection *pKeyValuePairs = dynamic_cast<NameValueCollection *>(pTempObj); Console::WriteLine( S"Config Set # {0}", i.ToString() ); if( pKeyValuePairs != 0 ) { IEnumerator *pEnumKeys = pKeyValuePairs->GetEnumerator(); while( pEnumKeys->MoveNext( ) ) { String *pKey = dynamic_cast<String *>(pEnumKeys->Current); Console::WriteLine( "Key {0} - Value {1}", pKey, pKeyValuePairs->Get( pKey ) ); } } Console::WriteLine( S"" ); } This is Managed C++, but you get the idea. For simplicity, I left out all the error handling that I would normally add to it. Cheers, Eddie -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Swaminathan S R Sent: Thursday, September 22, 2005 3:17 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] List of items in app.config You can have this in a custom config file and use Configuration Application Block to integrate with it. One requirement from your side will be to define a class for the custom config file, for serialization purposes. Some of the advantages you gain from using Configuration Application Block are 1. Respond to config changes at runtime, easily. 2. Persisting the modified configuration values. Config App Block : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/ html/config.asp - Swami -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Parag Mehta Sent: Thursday, September 22, 2005 11:49 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] List of items in app.config Hi Ed, Best solution for you is to implement a Config Section of your own and read it from your own class. To implement a configsection handler, all you have to do is implement IConfigurationSectionHandler interface. If you have msdn you can copy/paste this url it will be helpful : ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconcreatingnewsectionh andlers.htm Best Regards, Parag C Mehta, paragm.com On 9/22/05, Eddie Lascu <[EMAIL PROTECTED]> wrote: > Hello experts, > > I need to store an array of sets of configuration parameters in my > app.config file. There are a variable number of such sets, each set > having the exact structure. Something like this: > > <set1> > <param1>AAA</param1> > <param2>111</param2> > </set1> > <set2> > <param1>BBB</param1> > <param2>222</param2> > </set2> > <set3> > <param1>CCC</param1> > <param2>333</param2> > </set3> > > <!-- more sets added here --> > > How do I do this in the <appSettings> section of my app.config file? > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com