Cinchoo is the application framework for .NET. One of the main functionalities it provides to the users is application configuration management. Application configuration is the information that application reads and/or writes at run-time from the source.
Cinchoo framework simplifies the development with less code and read/write configuration values to the underlying data sources seamlessly. Also, it gives you the flexibility of interchanging the configuration sources through configuration without any code change.
Cinchoo configuration framework has the following powerful features:
- One single API to deal with configuration data with multiple sources
- Two-way, type-safe configuration management
- Create the configuration files, if those are missing
- Generate the configuration sections, if it does not exist
- During application run time, has the flexibility of changing the configuration sources without any restart or downtime needed
- Auto correct the section if it is missing any entries in the configuration files
In this section, I'll run through with a sample in creating and using configuration object in your application. This is the first of the series of articles. More will follow.
How to Use
- Download the 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
- Copy and paste the below configuration object:
public class AppSettings : ChoConfigurableObject
public string Name;
[ChoPropertyInfo("address", DefaultValue = "100, Madison Avenue, New York, NY 10010")]
public string Address;
All the configuration objects must derive from
ChoConfigurableObject class. Also, it must decorate with one of the below attributes depending on the type of configuration section storage you want to use:
ChoNameValueConfigurationSection - A file based Name/Value configuration section
ChoDictionaryConfigurationSection - A file based Key/Value pair configuration section
ChoSingleTagConfigurationSection - A file based Key/Value pair represented in single XML tag
ChoStandardAppSettingsConfigurationSection - Read/Write Key/Value pair from
ChoIniConfigurationSection - Read/Write configuration values from INI file
ChoRegistryConfigurationSection - Read/Write configuration value from System Registry
Add members to configuration object either as
Set Property or non-readonly field. You can optionally decorate them with
ChoPropertyInfoAttribute with source name, default value, etc.
Once you have the configuration object defined as above, it is now ready to use in your application. Here is how you can create and use it:
static void Main(string args)
AppSettings appSettings = new AppSettings();
appSettings.Name = "Raj";
Now compile this program and run. It will create the section in [appExeName].xml file under bin/Config folder.
<section name="appSettings" type="Cinchoo.Core.Configuration.ChoNameValueSectionHandler,
Cinchoo.Core, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b7dacd80ff3e33de" />
<add key="name" value="Tom" />
<add key="address" value="100, Madison Avenue, New York, NY 10010" />
It is very simple to work with configuration using Cinchoo framework. Try for yourself. Thanks.