Skip to content

rvignesh89/HumbleConfig

 
 

Repository files navigation

HumbleConfig

Stop writing boiler plate configuration code to pull from different sources.

HumbleConfig allows developers to concentrate on writing the application instead of managing all the configuration locations.

install from nugetdownloads Build status

Installing packages

PM> Install-Package HumbleConfig
PM> Install-Package HumbleConfig.ConfigurationManager
PM> Install-Package HumbleConfig.EnvironmentVariables
PM> Install-Package HumbleConfig.ConfigR
PM> Install-Package HumbleConfig.MongoDb

How to use it?

First, create an Configuration instance:

var configuration = new Configuration();

Then, configure the sources for configuration:

configuration.AddEnvironmentVariables()
             .AddConfigurationManager()
			 .AddConfigR()
			 .AddMongoDb("mongodb://localhost/settings", "appSettings");

We can also add some default values by using a InMemory source:

var defaults = new Dictionary<string, object>() { {"UserName", "Kevin.Smith"} };

configuration.AddInMemory(defaults);

Once we're happy with our configuration we can pull out an app setting:

var value = await configuration.GetAppSettingAysnc<string>("key");

Key formatters

Ever been in config hell where you don't know what key is used where. This is where key formatters comes in useful, HumbleConfig has inbuilt support for a few key formatters.

KeyPrefixer

The key prefixer allows you to specify a prefix that all your config keys should include. For example having a prefix of HumbleConfig: would have the following output:

Key Source Key
Key1 HumbleConfig:Key1
Key2 HumbleConfig:Key2
Key3 HumbleConfig:Key3

To setup this the key prefixer on our configuration object we just call WithKeyPrefixer:

configuration.WithKeyPrefixer("HumbleConfig:")

Contributing

  1. Fork
  2. Hack!
  3. Pull Request.

About

HumbleConfig is a simple abstraction on top of multiple config sources

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.5%
  • PowerShell 0.5%