Click here to Skip to main content
Licence 
First Posted 15 Aug 2002
Views 45,921
Downloads 1,186
Bookmarked 31 times

Custom application configuration. [With Editor Demo]

By Gevik Babakhani | 15 Aug 2002
This class helps you to create and modify custom configuration files for your application.

1

2

3
2 votes, 40.0%
4
3 votes, 60.0%
5
4.00/5 - 9 votes
μ 4.00, σa 1.10 [?]

Introduction

In the line of software development many times I have come across situations where I needed some kind of functionality to read, write and modify basic configuration options for my application. Here is a basic solution.

The ConfigManager helps developers to the same task in a very easy manner.

ConfigManager class has the following members:

  • ConfigManager() - Constructor, creates application.config file as the default configuration file
  • ConfigManager(string) - Constructor, creates a configuration file by given parameter which is filename.
  • bool AddValue(string key,object value) - Adds a value by key. The key is unique.
  • bool RemoveValue(string key,object value) - Removes a value by key.
  • object GetValue(string key,object default) - Returns a value by key or the default. Creates the entry if it doesn't exists.
  • ArrayList GetValues(string key,object default) - Returns an ArrayList of values.
  • bool UpdateValue(string key,object default) - Updates a value by key.

How to use the ConfigManager

Here is a simple example of how to use the ConfigManager's GetValues()

ConfigManager c = new ConfigManager();
ArrayList List = c.GetValues();

foreach(ConfigManagerKeyValue Item in List) {
    Console.WriteLine("{0,10} is {1,10}",Item.Key , Item.Value);
}

Have fun C#ing :)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Gevik Babakhani

Web Developer

Netherlands Netherlands

Member


Organisation (No members)

Gevik Babakhani is a software architect currently residing in The Netherlands. He started programming as hobby from the age of 12. His professional career began in 1997. Since then he works fulltime as a software architect. Currently he dedicates time and effort in Microsoft.NET.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralRun time changes Pinmemberpankajdc9:49 7 Oct '05  
GeneralGood work. Pinmemberwookie5:12 10 Jan '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120210.1 | Last Updated 16 Aug 2002
Article Copyright 2002 by Gevik Babakhani
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid