Cinchoo – Configuration framework, part 16

Configuration Meta Data Information

In this section I’m going to talk about Configuration Meta Data, a self described information about individual configuration object. This data used to control the behavior of the configuration object at any time (even at run time).

It can be controlled either by declarative or configuration.

First, I’ll discuss about specifying meta-data by declarative manner

Declarative Approach

All the configuration object must be decorated by ChoConfigurationSectionAttribute or one of the derived attributes.

  • BindingMode – Direction of configuration data flow.
    • TwoWay updates the target property or the property whenever either the target property or the source property changes. Default.
    • OneWay updates the target property only when the source property changes.
    • OneTime updates the target property only when the application starts.
    • OneWayToSource updates the source property when the target property changes.
  • Defaultable – true, will create the the section in the underlying configuration file if not present. Default is true.
  • ConfigStorageType – Type of the underlying configuration storage. Please visit Available Configuration Section Handlers for list of available storages.
  • ConfigFilePath – Absolute or relative file path to configuration file used by the configuration object.
  • ConfigFileNameFromTypeName – Configuration file name from Type name.
  • ConfigFileNameFromTypeFullName – Configuration file name from Type full name.
  • LogCondition – true, to allow log anything to the underlying log file using ConfigurationObject Log() method. Default value is true.
  • LogDirectory – Absolute or related path of the log directory. Default value is [Frameworklogdirectory]\Settings folder.
  • LogFileName – Log file name. Default value is Configuration Object Type full name.
  • LogTimeStampFormat – Log entry time stamp format. Default value is “yyyy-MM-dd hh:mm:ss.fffffff”.
  • Parameters – Reserved
  • Silent – true, will ignore any error while loading configuration parameters. Default is true.

Below is the sample configuration object decorated with meta-data information

[ChoConfigurationSection("applicationSettings", ConfigFileNameFromTypeName = typeof(SampleConfigSection), BindingMode = ChoConfigurationBindingMode.OneWay, LogDirectory = @"C:\Logs")]
public class SampleConfigSection : ChoConfigurableObject
	#region Instance Data Members (Public)

	[ChoPropertyInfo("name", DefaultValue="Mark")]
	public string Name;

	[ChoPropertyInfo("message", DefaultValue="Hello World!")]
	public string Message;


When you instantiate and use the above configuration object in your application, Cinchoo framework creates meta-data section in the meta-data file ([appExeName].config.meta) as below

<?xml version="1.0" encoding="utf-8"?>
  <applicationSettings bindingMode="OneWay" defaultable="true" silent="true">
    <logInfo condition="true" directory="Settings" fileName="SampleConfigSection.log" />

Configuration Approach

Cinchoo framework creates or uses the meta-data information in [appExeName].config.meta file by default.

This file name can be overridden. Please visit Framework Configuration Parameters section on how to do it.

Once file has been created and used by the framework, you have a chance to modify them to control the configuration object at run-time. Any changes made to this file automatically picked up framework and adjust the meta-data accordingly. Do not require restart of the application.

Also for any reason you have doubt about the values in the meta-data file, you can let the framework auto correct them by simple delete the a section from the meta-data file. Try for yourself.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s