Home All Groups Group Topic Archive Search About

How to write code for this XML configuration section?

Author
4 Apr 2006 9:18 AM
W. Jordan
Hello,

I would like to add a section in the configuration file like that:

<job name="cleanup">
    <executor type="Test.MyExecutor"/>
    <parameters>
        <string name="outputFile" value="C:\output.log" />
        <int name="maxValue" value="12" />
        <timespan name="timespan" value="0:0:15"/>
    </parameters>
</job>

A job can have multiple (0 to n) parameters. The parameters can be
some values, with a name, of any types.

How can I put it into the exe configuration file? And what kind of classes
should I build to support the configuration?


--


Best Regards,
W. Jordan

Author
4 Apr 2006 11:19 AM
Kevin Spencer
What version of the .Net Framework?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

Show quote
"W. Jordan" <wmjor***@163.com> wrote in message
news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I would like to add a section in the configuration file like that:
>
> <job name="cleanup">
>    <executor type="Test.MyExecutor"/>
>    <parameters>
>        <string name="outputFile" value="C:\output.log" />
>        <int name="maxValue" value="12" />
>        <timespan name="timespan" value="0:0:15"/>
>    </parameters>
> </job>
>
> A job can have multiple (0 to n) parameters. The parameters can be
> some values, with a name, of any types.
>
> How can I put it into the exe configuration file? And what kind of classes
> should I build to support the configuration?
>
>
> --
>
>
> Best Regards,
> W. Jordan
>
>
>
>
Author
6 Apr 2006 7:20 AM
W. Jordan
Oops, it is .net 2.0.

I saw something like ConfigurationSection, ConfigurationElement,
ConfigurationSectionGroup, and some other classes, but I did not
see an appropriate example of how to implement the XML config
that I posted at the beginning of this thread.

--


Best Regards,
W. Jordan



Show quote
"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
> What version of the .Net Framework?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
>
> Show me your certification without works,
> and I'll show my certification
> *by* my works.
>
> "W. Jordan" <wmjor***@163.com> wrote in message
> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
>> Hello,
>>
>> I would like to add a section in the configuration file like that:
>>
>> <job name="cleanup">
>>    <executor type="Test.MyExecutor"/>
>>    <parameters>
>>        <string name="outputFile" value="C:\output.log" />
>>        <int name="maxValue" value="12" />
>>        <timespan name="timespan" value="0:0:15"/>
>>    </parameters>
>> </job>
>>
>> A job can have multiple (0 to n) parameters. The parameters can be
>> some values, with a name, of any types.
>>
>> How can I put it into the exe configuration file? And what kind of
>> classes
>> should I build to support the configuration?
>>
>>
>> --
>>
>>
>> Best Regards,
>> W. Jordan
>>
>>
>>
>>
>
>
Author
6 Apr 2006 11:12 AM
Kevin Spencer
I'm not sure where you're looking, and therefore where you "saw" what you
saw. Since I don't know what resources you have available locally, I can
only point you to some references online.

First, the documentation for the .Net Framework 2.0 can be found at:
http://msdn2.microsoft.com/en-us/library/default.aspx

Notice that this is MSDN2, not MSDN.

Here are several other salient points of interest with regards to working
with Configuration in .Net 2.0:

http://msdn2.microsoft.com/en-us/library/kza1yk3a(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/sbk7ee6x(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/1fk1t1t0(VS.80).aspx

Now, as to the specifics, you will want to look over the
System.Configuration Namespace:

http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx

There are several classes in particular that you will work with most often:

http://msdn2.microsoft.com/en-us/library/system.configuration.configuration(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelement(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelementcollection(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectioncollection(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroup(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroupcollection(VS.80).aspx
( Look for the sample code included)

http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings(VS.80).aspx
( Look for the sample code included)

These are your major players. the .Net Framework 2.0 has a much more
powerful and strongly-typed Configuration model. You will need to create
some custom Configuration classes to work with your custom Configuration
Sections.

The bottom-most class is the ConfigurationElement class, which is used for
individual Configuration Elements, at the lowest node level of the XML.
Above this, you have the ConfigurationElementCollection, which manages a
collection of ConfigurationElements.

Generally, you will also need a ConfigurationSection, and possibly a
ConfigurationSectionGroup class to group your ConfigurationElements into
Sections.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.


Show quote
"W. Jordan" <wmjor***@163.com> wrote in message
news:O%2381ZqUWGHA.1352@TK2MSFTNGP05.phx.gbl...
> Oops, it is .net 2.0.
>
> I saw something like ConfigurationSection, ConfigurationElement,
> ConfigurationSectionGroup, and some other classes, but I did not
> see an appropriate example of how to implement the XML config
> that I posted at the beginning of this thread.
>
> --
>
>
> Best Regards,
> W. Jordan
>
>
>
> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
>> What version of the .Net Framework?
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Show me your certification without works,
>> and I'll show my certification
>> *by* my works.
>>
>> "W. Jordan" <wmjor***@163.com> wrote in message
>> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
>>> Hello,
>>>
>>> I would like to add a section in the configuration file like that:
>>>
>>> <job name="cleanup">
>>>    <executor type="Test.MyExecutor"/>
>>>    <parameters>
>>>        <string name="outputFile" value="C:\output.log" />
>>>        <int name="maxValue" value="12" />
>>>        <timespan name="timespan" value="0:0:15"/>
>>>    </parameters>
>>> </job>
>>>
>>> A job can have multiple (0 to n) parameters. The parameters can be
>>> some values, with a name, of any types.
>>>
>>> How can I put it into the exe configuration file? And what kind of
>>> classes
>>> should I build to support the configuration?
>>>
>>>
>>> --
>>>
>>>
>>> Best Regards,
>>> W. Jordan
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
7 Apr 2006 2:36 AM
W. Jordan
Hello Kevin,

I am sorry that I am inexperienced. I have the .Net Framework 2.0
Documentation installed on my machine. Thanks for pointing out the
locations of the online resources. I will learn those examples and
try to find out a way to implement my XML configuration sections.


--


Best Regards,
W. Jordan



Show quote
"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:uKK4JsWWGHA.4920@TK2MSFTNGP02.phx.gbl...
> I'm not sure where you're looking, and therefore where you "saw" what you
> saw. Since I don't know what resources you have available locally, I can
> only point you to some references online.
>
> First, the documentation for the .Net Framework 2.0 can be found at:
> http://msdn2.microsoft.com/en-us/library/default.aspx
>
> Notice that this is MSDN2, not MSDN.
>
> Here are several other salient points of interest with regards to working
> with Configuration in .Net 2.0:
>
> http://msdn2.microsoft.com/en-us/library/kza1yk3a(VS.80).aspx
> http://msdn2.microsoft.com/en-us/library/sbk7ee6x(VS.80).aspx
> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
> http://msdn2.microsoft.com/en-us/library/1fk1t1t0(VS.80).aspx
>
> Now, as to the specifics, you will want to look over the
> System.Configuration Namespace:
>
> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
>
> There are several classes in particular that you will work with most
> often:
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configuration(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelement(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelementcollection(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectioncollection(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroup(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroupcollection(VS.80).aspx
> ( Look for the sample code included)
>
> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings(VS.80).aspx
> ( Look for the sample code included)
>
> These are your major players. the .Net Framework 2.0 has a much more
> powerful and strongly-typed Configuration model. You will need to create
> some custom Configuration classes to work with your custom Configuration
> Sections.
>
> The bottom-most class is the ConfigurationElement class, which is used for
> individual Configuration Elements, at the lowest node level of the XML.
> Above this, you have the ConfigurationElementCollection, which manages a
> collection of ConfigurationElements.
>
> Generally, you will also need a ConfigurationSection, and possibly a
> ConfigurationSectionGroup class to group your ConfigurationElements into
> Sections.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
>
> Show me your certification without works,
> and I'll show my certification
> *by* my works.
>
>
> "W. Jordan" <wmjor***@163.com> wrote in message
> news:O%2381ZqUWGHA.1352@TK2MSFTNGP05.phx.gbl...
>> Oops, it is .net 2.0.
>>
>> I saw something like ConfigurationSection, ConfigurationElement,
>> ConfigurationSectionGroup, and some other classes, but I did not
>> see an appropriate example of how to implement the XML config
>> that I posted at the beginning of this thread.
>>
>> --
>>
>>
>> Best Regards,
>> W. Jordan
>>
>>
>>
>> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
>> news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
>>> What version of the .Net Framework?
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>> Professional Numbskull
>>>
>>> Show me your certification without works,
>>> and I'll show my certification
>>> *by* my works.
>>>
>>> "W. Jordan" <wmjor***@163.com> wrote in message
>>> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
>>>> Hello,
>>>>
>>>> I would like to add a section in the configuration file like that:
>>>>
>>>> <job name="cleanup">
>>>>    <executor type="Test.MyExecutor"/>
>>>>    <parameters>
>>>>        <string name="outputFile" value="C:\output.log" />
>>>>        <int name="maxValue" value="12" />
>>>>        <timespan name="timespan" value="0:0:15"/>
>>>>    </parameters>
>>>> </job>
>>>>
>>>> A job can have multiple (0 to n) parameters. The parameters can be
>>>> some values, with a name, of any types.
>>>>
>>>> How can I put it into the exe configuration file? And what kind of
>>>> classes
>>>> should I build to support the configuration?
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>> Best Regards,
>>>> W. Jordan
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
7 Apr 2006 1:06 PM
Kevin Spencer
Don't be discouraged. When I first started working with the new
configuration model, I had a hard time figuring it out myself.
Unfortunately, that was about a year ago, and I had nobody to point me to at
least the right classes and points of reference. Once I figured those out,
the rest was not so difficult.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

Show quote
"W. Jordan" <wmjor***@163.com> wrote in message
news:ep4gbweWGHA.4424@TK2MSFTNGP05.phx.gbl...
> Hello Kevin,
>
> I am sorry that I am inexperienced. I have the .Net Framework 2.0
> Documentation installed on my machine. Thanks for pointing out the
> locations of the online resources. I will learn those examples and
> try to find out a way to implement my XML configuration sections.
>
>
> --
>
>
> Best Regards,
> W. Jordan
>
>
>
> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> news:uKK4JsWWGHA.4920@TK2MSFTNGP02.phx.gbl...
>> I'm not sure where you're looking, and therefore where you "saw" what you
>> saw. Since I don't know what resources you have available locally, I can
>> only point you to some references online.
>>
>> First, the documentation for the .Net Framework 2.0 can be found at:
>> http://msdn2.microsoft.com/en-us/library/default.aspx
>>
>> Notice that this is MSDN2, not MSDN.
>>
>> Here are several other salient points of interest with regards to working
>> with Configuration in .Net 2.0:
>>
>> http://msdn2.microsoft.com/en-us/library/kza1yk3a(VS.80).aspx
>> http://msdn2.microsoft.com/en-us/library/sbk7ee6x(VS.80).aspx
>> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
>> http://msdn2.microsoft.com/en-us/library/1fk1t1t0(VS.80).aspx
>>
>> Now, as to the specifics, you will want to look over the
>> System.Configuration Namespace:
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
>>
>> There are several classes in particular that you will work with most
>> often:
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configuration(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelement(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelementcollection(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectioncollection(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroup(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroupcollection(VS.80).aspx
>> ( Look for the sample code included)
>>
>> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings(VS.80).aspx
>> ( Look for the sample code included)
>>
>> These are your major players. the .Net Framework 2.0 has a much more
>> powerful and strongly-typed Configuration model. You will need to create
>> some custom Configuration classes to work with your custom Configuration
>> Sections.
>>
>> The bottom-most class is the ConfigurationElement class, which is used
>> for individual Configuration Elements, at the lowest node level of the
>> XML. Above this, you have the ConfigurationElementCollection, which
>> manages a collection of ConfigurationElements.
>>
>> Generally, you will also need a ConfigurationSection, and possibly a
>> ConfigurationSectionGroup class to group your ConfigurationElements into
>> Sections.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Show me your certification without works,
>> and I'll show my certification
>> *by* my works.
>>
>>
>> "W. Jordan" <wmjor***@163.com> wrote in message
>> news:O%2381ZqUWGHA.1352@TK2MSFTNGP05.phx.gbl...
>>> Oops, it is .net 2.0.
>>>
>>> I saw something like ConfigurationSection, ConfigurationElement,
>>> ConfigurationSectionGroup, and some other classes, but I did not
>>> see an appropriate example of how to implement the XML config
>>> that I posted at the beginning of this thread.
>>>
>>> --
>>>
>>>
>>> Best Regards,
>>> W. Jordan
>>>
>>>
>>>
>>> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
>>> news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
>>>> What version of the .Net Framework?
>>>>
>>>> --
>>>> HTH,
>>>>
>>>> Kevin Spencer
>>>> Microsoft MVP
>>>> Professional Numbskull
>>>>
>>>> Show me your certification without works,
>>>> and I'll show my certification
>>>> *by* my works.
>>>>
>>>> "W. Jordan" <wmjor***@163.com> wrote in message
>>>> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
>>>>> Hello,
>>>>>
>>>>> I would like to add a section in the configuration file like that:
>>>>>
>>>>> <job name="cleanup">
>>>>>    <executor type="Test.MyExecutor"/>
>>>>>    <parameters>
>>>>>        <string name="outputFile" value="C:\output.log" />
>>>>>        <int name="maxValue" value="12" />
>>>>>        <timespan name="timespan" value="0:0:15"/>
>>>>>    </parameters>
>>>>> </job>
>>>>>
>>>>> A job can have multiple (0 to n) parameters. The parameters can be
>>>>> some values, with a name, of any types.
>>>>>
>>>>> How can I put it into the exe configuration file? And what kind of
>>>>> classes
>>>>> should I build to support the configuration?
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>> Best Regards,
>>>>> W. Jordan
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
23 Apr 2006 7:10 AM
Tim Johnson
There was a really excellent article on "The Last Configuration File I'll
Ever Need" that applied to .Net v1.0.

http://www.codinghorror.com/blog/archives/000161.html

But I've never seen any update anywhere related to .Net v2.0.  It basically
uses XML serialization to make generic section readers, as I understand it. 
Do you have any insight on an updated version of this valuable technique for
v2.0? 

Show quote
"Kevin Spencer" wrote:

> Don't be discouraged. When I first started working with the new
> configuration model, I had a hard time figuring it out myself.
> Unfortunately, that was about a year ago, and I had nobody to point me to at
> least the right classes and points of reference. Once I figured those out,
> the rest was not so difficult.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
>
> Show me your certification without works,
> and I'll show my certification
> *by* my works.
>
> "W. Jordan" <wmjor***@163.com> wrote in message
> news:ep4gbweWGHA.4424@TK2MSFTNGP05.phx.gbl...
> > Hello Kevin,
> >
> > I am sorry that I am inexperienced. I have the .Net Framework 2.0
> > Documentation installed on my machine. Thanks for pointing out the
> > locations of the online resources. I will learn those examples and
> > try to find out a way to implement my XML configuration sections.
> >
> >
> > --
> >
> >
> > Best Regards,
> > W. Jordan
> >
> >
> >
> > "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> > news:uKK4JsWWGHA.4920@TK2MSFTNGP02.phx.gbl...
> >> I'm not sure where you're looking, and therefore where you "saw" what you
> >> saw. Since I don't know what resources you have available locally, I can
> >> only point you to some references online.
> >>
> >> First, the documentation for the .Net Framework 2.0 can be found at:
> >> http://msdn2.microsoft.com/en-us/library/default.aspx
> >>
> >> Notice that this is MSDN2, not MSDN.
> >>
> >> Here are several other salient points of interest with regards to working
> >> with Configuration in .Net 2.0:
> >>
> >> http://msdn2.microsoft.com/en-us/library/kza1yk3a(VS.80).aspx
> >> http://msdn2.microsoft.com/en-us/library/sbk7ee6x(VS.80).aspx
> >> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
> >> http://msdn2.microsoft.com/en-us/library/1fk1t1t0(VS.80).aspx
> >>
> >> Now, as to the specifics, you will want to look over the
> >> System.Configuration Namespace:
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
> >>
> >> There are several classes in particular that you will work with most
> >> often:
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configuration(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelement(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelementcollection(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectioncollection(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroup(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroupcollection(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings(VS.80).aspx
> >> ( Look for the sample code included)
> >>
> >> These are your major players. the .Net Framework 2.0 has a much more
> >> powerful and strongly-typed Configuration model. You will need to create
> >> some custom Configuration classes to work with your custom Configuration
> >> Sections.
> >>
> >> The bottom-most class is the ConfigurationElement class, which is used
> >> for individual Configuration Elements, at the lowest node level of the
> >> XML. Above this, you have the ConfigurationElementCollection, which
> >> manages a collection of ConfigurationElements.
> >>
> >> Generally, you will also need a ConfigurationSection, and possibly a
> >> ConfigurationSectionGroup class to group your ConfigurationElements into
> >> Sections.
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> Professional Numbskull
> >>
> >> Show me your certification without works,
> >> and I'll show my certification
> >> *by* my works.
> >>
> >>
> >> "W. Jordan" <wmjor***@163.com> wrote in message
> >> news:O%2381ZqUWGHA.1352@TK2MSFTNGP05.phx.gbl...
> >>> Oops, it is .net 2.0.
> >>>
> >>> I saw something like ConfigurationSection, ConfigurationElement,
> >>> ConfigurationSectionGroup, and some other classes, but I did not
> >>> see an appropriate example of how to implement the XML config
> >>> that I posted at the beginning of this thread.
> >>>
> >>> --
> >>>
> >>>
> >>> Best Regards,
> >>> W. Jordan
> >>>
> >>>
> >>>
> >>> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
> >>> news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
> >>>> What version of the .Net Framework?
> >>>>
> >>>> --
> >>>> HTH,
> >>>>
> >>>> Kevin Spencer
> >>>> Microsoft MVP
> >>>> Professional Numbskull
> >>>>
> >>>> Show me your certification without works,
> >>>> and I'll show my certification
> >>>> *by* my works.
> >>>>
> >>>> "W. Jordan" <wmjor***@163.com> wrote in message
> >>>> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
> >>>>> Hello,
> >>>>>
> >>>>> I would like to add a section in the configuration file like that:
> >>>>>
> >>>>> <job name="cleanup">
> >>>>>    <executor type="Test.MyExecutor"/>
> >>>>>    <parameters>
> >>>>>        <string name="outputFile" value="C:\output.log" />
> >>>>>        <int name="maxValue" value="12" />
> >>>>>        <timespan name="timespan" value="0:0:15"/>
> >>>>>    </parameters>
> >>>>> </job>
> >>>>>
> >>>>> A job can have multiple (0 to n) parameters. The parameters can be
> >>>>> some values, with a name, of any types.
> >>>>>
> >>>>> How can I put it into the exe configuration file? And what kind of
> >>>>> classes
> >>>>> should I build to support the configuration?
> >>>>>
> >>>>>
> >>>>> --
> >>>>>
> >>>>>
> >>>>> Best Regards,
> >>>>> W. Jordan
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>
>
Author
23 Apr 2006 12:09 PM
Kevin Spencer
Configuration in .Net 2.0 is fundamentally different than in .Net 1.1. I
would advise you to stick with the resources I posted!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

Show quote
"Tim Johnson" <TimJohn***@discussions.microsoft.com> wrote in message
news:67B9BE2B-EF5A-4BA6-A54C-BBF04530A914@microsoft.com...
> There was a really excellent article on "The Last Configuration File I'll
> Ever Need" that applied to .Net v1.0.
>
> http://www.codinghorror.com/blog/archives/000161.html
>
> But I've never seen any update anywhere related to .Net v2.0.  It
> basically
> uses XML serialization to make generic section readers, as I understand
> it.
> Do you have any insight on an updated version of this valuable technique
> for
> v2.0?
>
> "Kevin Spencer" wrote:
>
>> Don't be discouraged. When I first started working with the new
>> configuration model, I had a hard time figuring it out myself.
>> Unfortunately, that was about a year ago, and I had nobody to point me to
>> at
>> least the right classes and points of reference. Once I figured those
>> out,
>> the rest was not so difficult.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Show me your certification without works,
>> and I'll show my certification
>> *by* my works.
>>
>> "W. Jordan" <wmjor***@163.com> wrote in message
>> news:ep4gbweWGHA.4424@TK2MSFTNGP05.phx.gbl...
>> > Hello Kevin,
>> >
>> > I am sorry that I am inexperienced. I have the .Net Framework 2.0
>> > Documentation installed on my machine. Thanks for pointing out the
>> > locations of the online resources. I will learn those examples and
>> > try to find out a way to implement my XML configuration sections.
>> >
>> >
>> > --
>> >
>> >
>> > Best Regards,
>> > W. Jordan
>> >
>> >
>> >
>> > "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
>> > news:uKK4JsWWGHA.4920@TK2MSFTNGP02.phx.gbl...
>> >> I'm not sure where you're looking, and therefore where you "saw" what
>> >> you
>> >> saw. Since I don't know what resources you have available locally, I
>> >> can
>> >> only point you to some references online.
>> >>
>> >> First, the documentation for the .Net Framework 2.0 can be found at:
>> >> http://msdn2.microsoft.com/en-us/library/default.aspx
>> >>
>> >> Notice that this is MSDN2, not MSDN.
>> >>
>> >> Here are several other salient points of interest with regards to
>> >> working
>> >> with Configuration in .Net 2.0:
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/kza1yk3a(VS.80).aspx
>> >> http://msdn2.microsoft.com/en-us/library/sbk7ee6x(VS.80).aspx
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
>> >> http://msdn2.microsoft.com/en-us/library/1fk1t1t0(VS.80).aspx
>> >>
>> >> Now, as to the specifics, you will want to look over the
>> >> System.Configuration Namespace:
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration(VS.80).aspx
>> >>
>> >> There are several classes in particular that you will work with most
>> >> often:
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configuration(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelement(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationelementcollection(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectioncollection(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroup(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsectiongroupcollection(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings(VS.80).aspx
>> >> ( Look for the sample code included)
>> >>
>> >> These are your major players. the .Net Framework 2.0 has a much more
>> >> powerful and strongly-typed Configuration model. You will need to
>> >> create
>> >> some custom Configuration classes to work with your custom
>> >> Configuration
>> >> Sections.
>> >>
>> >> The bottom-most class is the ConfigurationElement class, which is used
>> >> for individual Configuration Elements, at the lowest node level of the
>> >> XML. Above this, you have the ConfigurationElementCollection, which
>> >> manages a collection of ConfigurationElements.
>> >>
>> >> Generally, you will also need a ConfigurationSection, and possibly a
>> >> ConfigurationSectionGroup class to group your ConfigurationElements
>> >> into
>> >> Sections.
>> >>
>> >> --
>> >> HTH,
>> >>
>> >> Kevin Spencer
>> >> Microsoft MVP
>> >> Professional Numbskull
>> >>
>> >> Show me your certification without works,
>> >> and I'll show my certification
>> >> *by* my works.
>> >>
>> >>
>> >> "W. Jordan" <wmjor***@163.com> wrote in message
>> >> news:O%2381ZqUWGHA.1352@TK2MSFTNGP05.phx.gbl...
>> >>> Oops, it is .net 2.0.
>> >>>
>> >>> I saw something like ConfigurationSection, ConfigurationElement,
>> >>> ConfigurationSectionGroup, and some other classes, but I did not
>> >>> see an appropriate example of how to implement the XML config
>> >>> that I posted at the beginning of this thread.
>> >>>
>> >>> --
>> >>>
>> >>>
>> >>> Best Regards,
>> >>> W. Jordan
>> >>>
>> >>>
>> >>>
>> >>> "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
>> >>> news:eLPhqm9VGHA.4300@TK2MSFTNGP14.phx.gbl...
>> >>>> What version of the .Net Framework?
>> >>>>
>> >>>> --
>> >>>> HTH,
>> >>>>
>> >>>> Kevin Spencer
>> >>>> Microsoft MVP
>> >>>> Professional Numbskull
>> >>>>
>> >>>> Show me your certification without works,
>> >>>> and I'll show my certification
>> >>>> *by* my works.
>> >>>>
>> >>>> "W. Jordan" <wmjor***@163.com> wrote in message
>> >>>> news:ufkzLj8VGHA.5044@TK2MSFTNGP09.phx.gbl...
>> >>>>> Hello,
>> >>>>>
>> >>>>> I would like to add a section in the configuration file like that:
>> >>>>>
>> >>>>> <job name="cleanup">
>> >>>>>    <executor type="Test.MyExecutor"/>
>> >>>>>    <parameters>
>> >>>>>        <string name="outputFile" value="C:\output.log" />
>> >>>>>        <int name="maxValue" value="12" />
>> >>>>>        <timespan name="timespan" value="0:0:15"/>
>> >>>>>    </parameters>
>> >>>>> </job>
>> >>>>>
>> >>>>> A job can have multiple (0 to n) parameters. The parameters can be
>> >>>>> some values, with a name, of any types.
>> >>>>>
>> >>>>> How can I put it into the exe configuration file? And what kind of
>> >>>>> classes
>> >>>>> should I build to support the configuration?
>> >>>>>
>> >>>>>
>> >>>>> --
>> >>>>>
>> >>>>>
>> >>>>> Best Regards,
>> >>>>> W. Jordan
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>>
>>

AddThis Social Bookmark Button