Click here to Skip to main content
Click here to Skip to main content

Cinchoo - Configuration Object Binding Modes

, 26 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Available Binding Modes supported by Cinchoo configuration framework

Introduction

Cinchoo is the application framework for .NET. One of the main functionality it provides to the users is that application configuration management. Application configuration is the information that application reads and/or writes at run-time from the source.  Please take a look at 'Cinchoo - Simplified Configuration Manager' jump start article on using configuration framework in your application. 

In this article, I'll talk about the available binding modes supported by Cinchoo configuration framework. Binding mode is the direction of data flowing between Configuration object and datasource . Below are the list of binding modes available for us. (these are of ChoConfigurationBindingMode type) 

  1. TwoWay – (Default) The changes are flown both way between configuration section object and data source.
  2. OneWay – The changes are flown only from data source to configuration section object.
  3. OneWayToSource – The changes are flown only from configuration section object to data source.
  4. OneTime – The configuration settings are read and loaded into configuration section object once. Any changes made either in the configuration section object or data source are not propagated between them. 

Using the code 

There are couple of ways, you can specify binding mode for configuration object

  • Declarative
  • Configuration   

Declarative Way 

Using ChoConfigurationSectionAttribute, you can specify the binding mode as below 

[ChoConfigurationSection("sample", BindingMode = ChoConfigurationBindingMode.TwoWay)]
public class SampleConfigSection : ChoConfigurableObject
{
    [ChoPropertyInfo("name", DefaultValue = "Mark")]
    public string Name;

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

Configuration Way

Some cases, you may want to control the binding mode through configuration. This approach will help to prevent the code base being modified for each change. Here is how you can do 

  1. Open Bin/Config/Meta/[AppExeName].meta file
  2. Locate 'sample' element under 'configuration' node, modify BindingMode attribute.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <sample bindingMode="TwoWay" defaultable="true" silent="true" ignoreCase="true">
    <configStorage>Cinchoo.Core.Configuration.ChoFileNameValueConfigStorage, Cinchoo.Core, 
      Version=1.0.1.1, Culture=neutral, PublicKeyToken=b7dacd80ff3e33de</configStorage>
    <logInfo condition="true" directory="Settings" 
         fileName="MyFirstConfigSample.Program+AppSettings.log" />
  </sample>
</configuration> 

That's all. Try it. Thanks. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cinchoo

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411022.1 | Last Updated 26 Dec 2012
Article Copyright 2012 by Cinchoo
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid