PC Review


Reply
Thread Tools Rate Thread

more values in one section of app.config

 
 
Patrick
Guest
Posts: n/a
 
      2nd Oct 2003
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
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      2nd Oct 2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      2nd Oct 2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
 
Serge Calderara
Guest
Posts: n/a
 
      3rd Oct 2003
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
 
Patrick
Guest
Posts: n/a
 
      6th Oct 2003
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:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Caching config section values Thorsten Tarrach Microsoft ASP .NET 2 20th Aug 2009 09:01 AM
How to get values from custom config section? Showjumper Microsoft ASP .NET 1 25th Sep 2007 11:00 PM
Get Web.Config section shapper Microsoft ASP .NET 1 23rd Jun 2007 01:19 AM
Can I add my own section to the web.config ? craigkenisston@hotmail.com Microsoft ASP .NET 8 24th Sep 2006 06:15 PM
more values in one section of app.config Patrick Microsoft C# .NET 3 6th Oct 2003 02:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:22 AM.