473,626 Members | 3,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of Configurationse ttings 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" ?>
<configuratio n>
<configSections >
<!-- Definition of the User Management section -->
<sectionGroup name="UserManag ement">
<section name="settings"

type="System.Co nfiguration.Nam eValueSectionHa ndler" />
</sectionGroup>

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

type="System.Co nfiguration.Nam eValueSectionHa ndler" />
<section name="database"

type="System.Co nfiguration.Nam eValueSectionHa ndler" />
</sectionGroup>

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

type="System.Co nfiguration.Nam eValueSectionHa ndler" />
</sectionGroup>

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

type="System.Co nfiguration.Nam eValueSectionHa ndler" />
</sectionGroup>
</configSections>

<!-- Definition of the User management assembly setting
Parameter define in this section are only used by
UserMangement -->
<UserManagement >
<settings>
<add key="LastLoginN ame"
value="calderar a" />
<add key="RememberEn try" value="1" />
</settings>
</UserManagement>

<!-- Definition of the Configuration management
assembly setting
Parameter define in this section are only used by
UserMangement -->
<ConfigurationM anagement>
<settings>
<add key="ConfigSave d" value="yes" />
<add key="AccessProv iderDNS"
value="Provider =Microsoft.Jet. OLEDB.4.0;Data Source=" />
</settings>
<database>
<add key="Path" value="E:\Confi guration data
base" />
<add key="DNS"
value="Provider =Microsoft.Jet. OLEDB.4.0;Data Source=" />
<add key="sqlserver" value="true" />
</database>
</ConfigurationMa nagement>

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

<!-- 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="LogFilePat h" 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.diagnos tics>
<switches>
<add name="Enabled" value="1" />
<add name="TraceSeve rity" value="1" />
</switches>
</system.diagnost ics>
</configuration>

What is the best way to access and return those different
settings ?
Should I go with ConfigurationSe ttings 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 2123
Hi Serge,
What is the best way to access and return those different
settings ?
Should I go with ConfigurationSe ttings class or use of
XMLDocument class ?
Go for the ConfigurationSe ttings class, e.g.

NameValueCollec tion userManagement;
userManagement = ConfigurationSe ttings.GetConfi g("UserManageme nt")
as NameValueCollec tion;

and dereference like this:

userManagement["LastLoginN ame"]...

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 Configurationse tting class for the time beeing.
But then I have one question:

How to know if the request parameter is valid ?

Exaemple:
userManagement = ConfigurationSe ttings.GetConfi g("UserManageme nt")

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

userManagement["LastLoginN ame"]...

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******** ******@TK2MSFTN GP10.phx.gbl...

userManagement["LastLoginN ame"]...

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
3599
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 instruction document (not data based) - same as using an xml web control. The resulting html is on the client? but what about the server side of things? Trying to figure out how to change and save the xmlDocument. It I put a button OUTSIDE of the...
2
6402
by: Mythran | last post by:
public static void Main() { string sectionName = "system.web"; object settings = ConfigurationSettings.GetConfig(sectionName); Console.WriteLine( settings == null ? "(null)" : settings.GetType().ToString() ); }
3
1543
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 every time I access it. I want to define the connection string in the web app ConfigurationSettings and let the class library reference it itself whenever it needs a connection. How can I do this?
3
219
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 : ===================================================== <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
0
8266
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.