473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Use of Configurationsettings or XMLDocument class ????

Dear all,

I have define a configuration file for my application with
different section groups and settings belonging to each
individual group like as follow :

================================================== ===
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<!-- Definition of the User Management section -->
<sectionGroup name="UserManagement">
<section name="settings"

type="System.Configuration.NameValueSectionHandler " />
</sectionGroup>

<!-- Definition of the Configuration Mangement
section -->
<sectionGroup name="ConfigurationManagement">
<section name="settings"

type="System.Configuration.NameValueSectionHandler " />
<section name="database"

type="System.Configuration.NameValueSectionHandler " />
</sectionGroup>

<!-- Definition of the Language Management section -->
<sectionGroup name="LanguageManagement">
<section name="settings"

type="System.Configuration.NameValueSectionHandler " />
</sectionGroup>

<!-- Definition of the HMI builder Management section --
<sectionGroup name="HMIBuilder">
<section name="settings"

type="System.Configuration.NameValueSectionHandler " />
</sectionGroup>
</configSections>

<!-- Definition of the User management assembly setting
Parameter define in this section are only used by
UserMangement -->
<UserManagement>
<settings>
<add key="LastLoginName"
value="calderara" />
<add key="RememberEntry" value="1" />
</settings>
</UserManagement>

<!-- Definition of the Configuration management
assembly setting
Parameter define in this section are only used by
UserMangement -->
<ConfigurationManagement>
<settings>
<add key="ConfigSaved" value="yes" />
<add key="AccessProviderDNS"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" />
</settings>
<database>
<add key="Path" value="E:\Configuration data
base" />
<add key="DNS"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" />
<add key="sqlserver" value="true" />
</database>
</ConfigurationManagement>

<!-- Definition of the Language management assembly setting
Parameter define in this section are only used by
UserMangement -->
<LanguageManagement>
<settings>
<add key="Default" value="English" />
</settings>
</LanguageManagement>

<!-- Definition of the HMI builder assembly setting
Parameter define in this section are only used by
UserMangement -->
<HMIBuilder>
<settings>
<add key="XPos" value="100" />
</settings>
</HMIBuilder>

<!-- Definition of the application setting
Find here any parameters for the global application
startup phase
key : represent the name of the key to scan
value: represent the actual value of the found key --

<appSettings>
<add key="LogFile" value="TraceLog.txt" />
<add key="LogFilePath" value="C:" />
</appSettings>
<!-- Definition of the tracing operation
bActivate : Set tracing to ON or OFF (1=ON, 0=OFF)
TraceSeverity : define what type of message level
should be trace based
on TraceLevel (none, info, warning,fatal, verbose =
0,1,2,3,4)
Note that a value of 3 will trace also level 1 and
2 -->
<system.diagnostics>
<switches>
<add name="Enabled" value="1" />
<add name="TraceSeverity" value="1" />
</switches>
</system.diagnostics>
</configuration>

What is the best way to access and return those different
settings ?
Should I go with ConfigurationSettings class or use of
XMLDocument class ?

If A request is send to retrive parameter for a group I
should be able to rertreve all entry at once even if it
has different section.

thanks for your comments
regards
Jul 21 '05 #1
3 2093
Hi Serge,
What is the best way to access and return those different
settings ?
Should I go with ConfigurationSettings class or use of
XMLDocument class ?
Go for the ConfigurationSettings class, e.g.

NameValueCollection userManagement;
userManagement = ConfigurationSettings.GetConfig("UserManagement")
as NameValueCollection;

and dereference like this:

userManagement["LastLoginName"]...

I think this is easier than using the XMLDocument class.
If A request is send to retrive parameter for a group I
should be able to rertreve all entry at once even if it
has different section.


Through the collection above you can retrieve any value in that group.

---
Steven Wood
Jul 21 '05 #2
Thanks for your answer,

I go with Configurationsetting class for the time beeing.
But then I have one question:

How to know if the request parameter is valid ?

Exaemple:
userManagement = ConfigurationSettings.GetConfig("UserManagement")

I need first to be sure that the section "UserMangement is still present
and if not return an error
or by this :

userManagement["LastLoginName"]...

I need toi be sure first that LastLoginname is really present and if not
return an erro as well.

What is the way to identify that a section or group is present?

thanks for your answer
regards
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Hi Serge,

"calderara serge" <se*************@maillefer.net> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...

userManagement["LastLoginName"]...

I need toi be sure first that LastLoginname is really present and if not
return an erro as well.

What is the way to identify that a section or group is present?


Well, you could check for a null and for extra safety use a try..catch
handler.

---
Steven Wood
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
2
by: Mythran | last post by:
public static void Main() { string sectionName = "system.web"; object settings = ConfigurationSettings.GetConfig(sectionName); Console.WriteLine( settings == null ? "(null)" :...
3
by: Random | last post by:
I'm writing a class library for my web app data access, but don't want to hard code the database connection string in the class. Nor do I want to pass the connection string in from the web app...
3
by: serge calderara | last post by:
Dear all, I have define a configuration file for my application with different section groups and settings belonging to each individual group like as follow : ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.