Cinchoo is an application framework for .NET. One of the main functionality it provides to users is the application configuration management. Application configuration is information that an application reads and/or writes at run-time from the source.
Please visit jump start article [Cinchoo - Simplified Configuration Manager] for more information about Cinchoo configuration manager.
In this section, I'll show you with sample using INI section information using the Cinchoo configuration framework. It provides the opportunity in using legacy configuration maintained in Windows INI files from your .NET applications.
How to use
- Download latest Cinchoo binary here.
- Open VS.NET 2010 or higher
- Create a sample VS.NET (.NET Framework 4) Console Application project.
- Add reference to Cinchoo.Core.dll
- Use the
- Define a configuration object '
ApplicationSettings' as below.
[ChoIniConfigurationSection("applicationSettings", "ADDRESS", @"TestIni.ini")]
public class ApplicationSettings : ChoConfigurableObject
[ChoPropertyInfo("STREET", DefaultValue = "1200, MAY ST")]
public string Street;
[ChoPropertyInfo("CITY", DefaultValue = "BOSTON")]
public string City;
[ChoPropertyInfo("STATE", DefaultValue = "MA")]
public string State;
[ChoPropertyInfo("ZIP", DefaultValue = "98760")]
public string Zip;
- In order to be configurable object, it must derive from
- It must be decorated using
ChoIniConfigurationSectionAttribute, so that this object will use the INI file as the configuration source. The
three key parameters are, configuration element path (
applicationSettings), INI section name (
ADDRESS) and INI file name (TestIni.ini). INI file name can be absolute or relative path. If the file not exists, it will be created automatically. Also if the INI section and INI key-values not found, those will be created automatically as well.
Once you have class declared as above, it is now ready use INI file as simple as creating object out of it. Any changes made to this object as well as in the INI file will be exchanged automatically. The sample code as below
static void Main(string args)
ApplicationSettings applicationSettings = new ApplicationSettings();
That's all. A sample project is attached. Download and try for yourself.
The configuration section attribute (i.e.,
ChoIniConfigurationSectionAttribute) parameters like INI section name, INI filename etc. can be adjusted through application configuration file. It avoids rebuilding your binary for each such change. Here is how you can do it.
[appExeName].xml file under the bin/config folder. This file usually created very first time run your application. Look for xml node named configuration element path (
Cinchoo.Core, Version=184.108.40.206, Culture=neutral,
Take a closer look at '
applicationSettings' XML node, you may notice two attributes '
iniSectionName' and '
iniFilePath'. There two attributes controls the INI source information that Cinchoo framework reads and loads them into configuration object members. You can change these parameters. Will require restart of your application in order to take the new parameters into effect. Hope this helps.