PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET more values in one section of app.config

Reply

more values in one section of app.config

 
Thread Tools Rate Thread
Old 02-10-2003, 04:14 PM   #1
Patrick
Guest
 
Posts: n/a
Default more values in one section of app.config


Hi

I want tu use an app.config like the example below. The problem is, that i
don't know how many Action-Tags there will be, because this can be changed
by the user. When using
System.Configuration.ConfigurationSettings.GetConfig("IncomingActions/action
") I can access the config file, but get only the values of the Last
Action-Tag.


Does someone know, how to implement that using the app.config file?

Thanks

Patrick





<configSections>

<sectionGroup name="IncomingActions">

<section name="action"
type="System.Configuration.SingleTagSectionHandler" />

</sectionGroup>

</configSections>

<IncomingActions>

<action From="Value11" Message="value two1" Command="third value1"
Confirm="y" />

<action From="Value21" Message="value two2" Command="third value2"
Confirm="y" />

<action From="Value31" Message="value two3" Command="third value3"
Confirm="y" />

<action From="Value41" Message="value two4" Command="third value4"
Confirm="y" />

</IncomingActions>


  Reply With Quote
Old 02-10-2003, 04:53 PM   #2
Ignacio Machin \( .NET/ C# MVP \)
Guest
 
Posts: n/a
Default Re: more values in one section of app.config

Hi Patrick,

I would suggest you put those config settings in another XML file, so you
can parse it and create a collection ( or maybe a Hashtable ) to contain
them.
You can create a class Config with a static constructor ( to be sure it will
be called before you use this class ) from where you load/parse the config.

Then you can have properties ( I suggest static too ) that you have access
to the settings.


Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Patrick" <patrick911@bluemail.ch> wrote in message
news:1065104230.245248@fuchs.cyberlink.ch...
> Hi
>
> I want tu use an app.config like the example below. The problem is, that i
> don't know how many Action-Tags there will be, because this can be changed
> by the user. When using
>

System.Configuration.ConfigurationSettings.GetConfig("IncomingActions/action
> ") I can access the config file, but get only the values of the Last
> Action-Tag.
>
>
> Does someone know, how to implement that using the app.config file?
>
> Thanks
>
> Patrick
>
>
>
>
>
> <configSections>
>
> <sectionGroup name="IncomingActions">
>
> <section name="action"
> type="System.Configuration.SingleTagSectionHandler" />
>
> </sectionGroup>
>
> </configSections>
>
> <IncomingActions>
>
> <action From="Value11" Message="value two1" Command="third value1"
> Confirm="y" />
>
> <action From="Value21" Message="value two2" Command="third value2"
> Confirm="y" />
>
> <action From="Value31" Message="value two3" Command="third value3"
> Confirm="y" />
>
> <action From="Value41" Message="value two4" Command="third value4"
> Confirm="y" />
>
> </IncomingActions>
>
>



  Reply With Quote
Old 02-10-2003, 06:56 PM   #3
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: more values in one section of app.config

Patrick,
In addition to Ignacio's suggestion of creating "another XML" file.

You can actually do this with a single XML file the app.config itself.

The trick is, instead of defining IncomingActions as a sectionGroup with a
nested SingleTagSectinoHandler. You define IncomingActions as a custom
Configuration Section Handler. You do this by implementing the
System.Configuration.IConfigurationSectionHandler interface, then using the
XML dom parse the XML Node.

I would have the IncomingActions handler return a collection of Action
objects.

I do not have a link to a handy sample right now. If you need one post and I
will try to find the links to the two or three I found earlier.

Hope this helps
Jay

"Patrick" <patrick911@bluemail.ch> wrote in message
news:1065104230.245248@fuchs.cyberlink.ch...
> Hi
>
> I want tu use an app.config like the example below. The problem is, that i
> don't know how many Action-Tags there will be, because this can be changed
> by the user. When using
>

System.Configuration.ConfigurationSettings.GetConfig("IncomingActions/action
> ") I can access the config file, but get only the values of the Last
> Action-Tag.
>
>
> Does someone know, how to implement that using the app.config file?
>
> Thanks
>
> Patrick
>
>
>
>
>
> <configSections>
>
> <sectionGroup name="IncomingActions">
>
> <section name="action"
> type="System.Configuration.SingleTagSectionHandler" />
>
> </sectionGroup>
>
> </configSections>
>
> <IncomingActions>
>
> <action From="Value11" Message="value two1" Command="third value1"
> Confirm="y" />
>
> <action From="Value21" Message="value two2" Command="third value2"
> Confirm="y" />
>
> <action From="Value31" Message="value two3" Command="third value3"
> Confirm="y" />
>
> <action From="Value41" Message="value two4" Command="third value4"
> Confirm="y" />
>
> </IncomingActions>
>
>



  Reply With Quote
Old 03-10-2003, 08:26 AM   #4
Serge Calderara
Guest
 
Posts: n/a
Default more values in one section of app.config

Hi

Instead of defining you section type as :
type="System.Configuration.SingleTagSectionHandler


use the following :
type="System.Configuration.NameValueSectionHandler

Then use the getCongig function that return a
NameValueColection an all value will be then retrive from
the section.

U can then browse the desired item of the collection and
process accordingly.

That works really fine, I am doing it like that for my app
config file whcih have different section group

regards
serge

>-----Original Message-----
>Hi
>
>I want tu use an app.config like the example below. The

problem is, that i
>don't know how many Action-Tags there will be, because

this can be changed
>by the user. When using
>System.Configuration.ConfigurationSettings.GetConfig

("IncomingActions/action
>") I can access the config file, but get only the values

of the Last
>Action-Tag.
>
>
>Does someone know, how to implement that using the

app.config file?
>
>Thanks
>
>Patrick
>
>
>
>
>
><configSections>
>
> <sectionGroup name="IncomingActions">
>
> <section name="action"
>type="System.Configuration.SingleTagSectionHandler" />
>
> </sectionGroup>
>
></configSections>
>
><IncomingActions>
>
> <action From="Value11" Message="value two1"

Command="third value1"
>Confirm="y" />
>
> <action From="Value21" Message="value two2"

Command="third value2"
>Confirm="y" />
>
> <action From="Value31" Message="value two3"

Command="third value3"
>Confirm="y" />
>
> <action From="Value41" Message="value two4"

Command="third value4"
>Confirm="y" />
>
></IncomingActions>
>
>
>.
>

  Reply With Quote
Old 06-10-2003, 02:46 PM   #5
Patrick
Guest
 
Posts: n/a
Default Re: more values in one section of app.config

so there is no way to make this with the usual config stuff.... for the
other i have already my own xml-config reader, for complexer settings, but
okay, thanks for that hint


"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schrieb im Newsbeitrag news:%23TpBJUPiDHA.2452@TK2MSFTNGP10.phx.gbl...
> Hi Patrick,
>
> I would suggest you put those config settings in another XML file, so you
> can parse it and create a collection ( or maybe a Hashtable ) to contain
> them.
> You can create a class Config with a static constructor ( to be sure it

will
> be called before you use this class ) from where you load/parse the

config.
>
> Then you can have properties ( I suggest static too ) that you have

access
> to the settings.
>
>
> Hope this help,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
> "Patrick" <patrick911@bluemail.ch> wrote in message
> news:1065104230.245248@fuchs.cyberlink.ch...
> > Hi
> >
> > I want tu use an app.config like the example below. The problem is, that

i
> > don't know how many Action-Tags there will be, because this can be

changed
> > by the user. When using
> >

>

System.Configuration.ConfigurationSettings.GetConfig("IncomingActions/action
> > ") I can access the config file, but get only the values of the Last
> > Action-Tag.
> >
> >
> > Does someone know, how to implement that using the app.config file?
> >
> > Thanks
> >
> > Patrick
> >
> >
> >
> >
> >
> > <configSections>
> >
> > <sectionGroup name="IncomingActions">
> >
> > <section name="action"
> > type="System.Configuration.SingleTagSectionHandler" />
> >
> > </sectionGroup>
> >
> > </configSections>
> >
> > <IncomingActions>
> >
> > <action From="Value11" Message="value two1" Command="third value1"
> > Confirm="y" />
> >
> > <action From="Value21" Message="value two2" Command="third value2"
> > Confirm="y" />
> >
> > <action From="Value31" Message="value two3" Command="third value3"
> > Confirm="y" />
> >
> > <action From="Value41" Message="value two4" Command="third value4"
> > Confirm="y" />
> >
> > </IncomingActions>
> >
> >

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off