System.Configuration
namespace. The namespace holds the classes the .NET framework uses to work on and with configuration files. The major issue with the default configuration namespace is that it is very opinionated about how configurations should be structured and saved (see app.config
and web.config
for details). This library aims to address those issues.
Get the library from Nuget by using a GUI or a package manager
Install-Package PropertyConfig.dll
Add the directive to your class file:
using PropertyConfig;
Instantiate the class (preferably in the main entry class and storing it in a static variable)
public static Configuration configuration = new Configuration();
Add whatever properties necessary, for example
configuration["Hello"] = "World";
//or
configuration.Add("Hello", "World");
After including every property, save the configuration
configuration.StoreToXml(); //saves to the default 'config.xml'
//or
configuration.StoreToXml(/*path to custom xml file*/); //saves to specified xml file
//or
configuration.StoreToXml(/*path to custom xml file*/, /*comment to add to config files*/);
this produces an output that looks like
To load a config file
configuration.LoadFromXml() //loads from default 'config.xml'
//or
configuration.LoadFromXml(/*path to custom xml file*/); //saves to specified xml file
Property Config has the following features; You can save configuration files as XML. It allows for loading, modifying and saving of configuration files with minimal amount of code. It is beginner friendly.
It adds the default features for saving and loading XML config files.