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

Cinchoo - ConfigurationManager Tips 1

, 21 Apr 2013
Rate this:
Please Sign up or sign in to vote.
This tip shows how to attach configuration files to your applications

Introduction

Cinchoo is the application framework for .NET. One of the main functionalities that it provides to the users is application configuration management. Application configuration is the information that the 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 section, I'll talk about a way to hook up the existing configuration files to your files through application configuration file. And how to set environment specific configuration files to the applications.

Using Existing Configuration Files

If you have existing configuration files or you want to share the configuration files with multiple applications, you can do so by specifying the folder path in the application configuration file (App.config) as below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="appFrxSettings" type="Cinchoo.Core.ChoAppFrxSettings, Cinchoo.Core" />
    </configSections>
    <appFrxSettings appFrxFilePath="C:\ConfigFolder" 
	sharedEnvironmentConfigFilePath="" appEnvironment="" />
</configuration> 

As you probably know, it is custom configuration section 'Cinchoo.Core.ChoAppFrxSettings' defined in App.config file.

  • appFrxFilePath - Optional. Absolute path to the configuration files directory to use by your application. If not given, 'Config' folder will be created under executable directory.
  • sharedEnvironmentConfigFilePath - Optional. Absolute/relative file path of shared environment configuration file. If not passed, your applications will not be using any environment specific configuration files.
  • appEnvironment - Optional. Environment name, the application will pick up the configuration files tied to the environment. If not specified, will pickup the configuration files tied to the machine from environment configuration file.

Shared Environment

In a situation, where you want to keep and maintain configuration files for each environment (DEV, UAT and PROD, etc.) separately in a centralized location and have them discovered and attached to your application automatically, all of them can be done through Shared Environment Configuration file.

Normally Cinchoo framework discovers this file (SharedEnvironment.config) in the application configuration folder if not specified explicitly. It can be overridden to different file path through 'sharedEnvironmentConfigFilePath' attribute in the above section in App.config file.

Specification of the SharedEnvironment configuration file is as below:

<?xml version="1.0"?>
<configuration>
  <sharedEnvironment defaultEnvironment="DEV">
    <environment name="DEV" appFrxFilePath="Config\DEV" freeze="true" > 
      <machine>WNYC12D10101</machine>
      <machine>WNYC12D10102</machine>
      <machine>WNYC12D10103</machine>
      <machine>WNYC12D10104</machine>
    </environment>
    <environment name="PROD" appFrxFilePath="C:\Config\PROD" freeze="true" >
      <machine>SNYC12D10101</machine>
      <machine>100.39.191.175</machine>
    </environment>
    <environment name="UAT" >
      <machine>WNYC1108054621</machine>
      <machine>SNYC*</machine>
    </environment>
  </sharedEnvironment>
</configuration>    

Each environment can be given with 'environment' section with 'name' attribute, aka environment name. Group of machines can be associated with environment through 'machine' elements. Wild card values may be accepted as machine names. Machine names can be IP addresses or readable machine names.

An environment may be frozen (locked) by specifying 'freeze' tag to true. It means that the application environment is locked for those machines. Your applications running on those machines can NOT be overridden the environment through 'appEnvironment' attribute in the ChoAppFrxSettings section in the App.config file.

Path to configuration files for each environment can be given through 'appFrxFilePath' attribute. It can be either absolute or relative file path to a folder.

Any machines not configured/specified in this shared environment file will pick up the configuration files that belong to environment specified in 'defaultEnvironment' attribute in 'sharedEnvironment' section.

That's all folks. Try for yourself.

License

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

About the Author

Cinchoo

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 21 Apr 2013
Article Copyright 2013 by Cinchoo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid