This project is read-only.

Project Description
Appblock config allow load configurations all *.config files in an application context. This appblock allow define multiple profiles.

This appblock can handle easily and simple settings of an application. It can use in Web applications and desktop applications. Among the features are:

  • Division multiple configuration files without the attribute " configSource "
  • Hierarchy of configuration files
  • Load config files from Environment
  • Encrypt / decrypt blocks simple configuration

Using AppBlock.Config

Simply call the method of loading configurations to start an application (either in the global.asax or in constructor of application for desktop applications).

ConfigManager.LoadConfigurations();

If you want to specify configuration files to load higher level in the folder hierarchy of the application just tell the number of levels of parent directory:

ConfigManager.LoadConfigurations(1);

This module also allows you to define specific configurations based on the name of the machine running, making it easy to load specific configurations depending on the environment where it runs.


Example: we have three environments, C1, C2 and C3. Simply declare within one of our applications 'Config' folder containing a folder or specific configuration environment. Once created files must specify the properties of the files that are copied to the output directory to compile the application:

When you run the application invoking LoadConfigurations() common configurations are loaded and supplemented with specific environment settings. This allows configurations organized separating the common part of the specific (no need for changes in xml files).

Furthermore, suppose we want to load the configuration of a particular environment, to try settings that environment or play an error. It is as simple as specifying the level where the configuration files (zero if the application root) and name of the environment will be loaded:

ConfigManager.LoadConfigurations(0, "C3");

 

ConfigHelper

This module contains a helper that makes it easy to obtain the appSettings configuration section and return default values ​​(instead of throwing an exception). This improves your application failure resistance.

 AppBlocks.ConfigHelper.GetAppSetting<int>(“CounterValue”);

this method returns 0 if key  does not exists 

 

AppBlocks.ConfigHelper.GetAppSetting<int>(“CounterValue”, 1);

this method returns 1 if key does not exist

 

 AppBlocks.ConfigHelper.GetAppSetting(“StringKey”);

this method returns the string value. If does not exists returns null.

 

 

Last edited Dec 17, 2013 at 10:36 AM by druizgui, version 12