Cinchoo – Configuration framework, part 23

Passing Configuration FilePath Programmatically

UPDATED: In this topic, I’m going to show you how to pass configuration object filepath programmatically. Cinchoo framework addresses this feature through IChoConfigurationParametersOverridable¬†interface. When you define a configuration object, implement this interface as below to override the configuration file path.

[ChoNameValueConfigurationSection("applicationSettings")]
public class ApplicationSettings : ChoConfigurableObject
{
    [ChoPropertyInfo("path", DefaultValue = @"C:\")]
    public string Path;

    [ChoPropertyInfo("OS", DefaultValue = "Windows")]
    public string OS;

    protected override void OverrideMetaDataInfo(ChoBaseConfigurationMetaDataInfo metaDataInfo)
    {
        ChoStandardConfigurationMetaDataInfo info = metaDataInfo as ChoStandardConfigurationMetaDataInfo;
        info.ConfigFilePath = @"C:\Test\ApplicationSettings.xml";
    }
}
About these ads

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s