Creating A Configuration Settings Object

S

Steven Cheng[MSFT]

Hi J,

As for creating custom configuration section for .NET framework application
configuration file, you have two means according to the .net framework 2.0
configuration section handler interface:

1. Use the existing configuration classes to build your custom
comfigurationSection in a declarative way.

#How to: Create Custom Configuration Sections Using ConfigurationSection
http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx

http://www.codeproject.com/dotnet/customconfigsectionsNet2.asp


2. Using built-in classes may have few customzation ability such as control
the exact element name or collection section's child elements. thus, you
can also build a custom section through complete programmatic way by using
the IConfigurationSectionHandler interface:

#How to: Create Custom Configuration Sections Using
IConfigurationSectionHandler
http://msdn2.microsoft.com/en-us/library/ms228056.aspx

in this case, you will write all the code that do the xml reading/writing
for your custom section

Here is a list of all those .NET 2.0 configuration section classes you can
use:

#Classes Used to Create Custom Section Handlers
http://msdn2.microsoft.com/en-us/library/ms228062(vs.80).aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

For the most part, the built in stuff is working for me. The one thing that
i would like is to be able to have config sections within sections...

So I can reference settings like such:

My.Settings.Setting1
My.Settings.Setting2
My.Settings.Category1.Setting1
My.Settings.Category2.Setting2

Is there a way to have this sort of hierarchical settings configuration with
the built in stuff?

Thanks.

J
 
S

Steven Cheng[MSFT]

Thanks for your reply J,

As for the hierarchical setting you mentioned, here is my understanding:

the .NET framework configuration system can only support the following
section/group hierarchy:

* a certain section directly under the <configuration> root
* a certain section under a section group(like <system.web>) and other
sections nested under that section group

so far I haven't found any reference about nested sections in other
sections.

As for the My.Settings.Category2.Setting2 like section, one way to
achive this setting structure is a below:

* create a custom section, this is the "My"

* in "My" configuration section, define "Settings" as a sub property(of
ConfigurationElement derived type)

* in "Settings" configuration Element you define "Category2" as a sub
property

* in "Category2" configuration Element class, you define "Setting2" as a
sub property

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top