Coder Social home page Coder Social logo

konfiggy's Introduction

#Konfiggy

Konfiggy is a tiny helper utility for making life easier when dealing with environment-dependent configuration settings in your app/web.config files.

NuGet install

Install-Package Konfiggy

Elevator pitch

Konfiggy enables you to write your app/web.configs like this:

<appSettings>
    <add key="dev.mySetting" value="dev-specific-value" />
    <add key="qa.mySetting" value="qa-specific-value" />
    <add key="prod.mySetting" value="prod-specific-value" />
</appSettings>

You then configure Konfiggy to resolve the dev, qa, or prod tags (you can use whatever tags/names you want) in some way. The built-in methods include

  • Machine Environment Variable
  • Conditional Compilation
  • In code
  • A dictionary of machine names
  • A file on disk

And query your appSetting/connectionString like this:

IKonfiggy konfiggy = new Konfiggy(); // Or resolve from IoC...
string myValue = konfiggy.GetAppSetting("mySetting");

And also...

With a POCO class like

class Config
{
    public string MySetting { get; set; }
    public string MyConnectionString { get; set; }
}

And a app.config file like

<appSettings>
  <add key="dev.mySetting" value="foo"/>
</appSettings>
<connectionStrings>
  <add name="dev.myConnectionString" connectionString="bar"/>
</connectionStrings>

You can automatically populate it with config data

var config = konfiggy.PopulateConfig<Config>()
                     .WithAppSettings()
                     .WithConnectionStrings()
                     .Populate();

Or map the properties manually if the names doesn't match exactly

var config = konfiggy.PopulateConfig<Config>()
                     .WithAppSettings(c => c.Map(x => x.MySetting, "someAppSettingKey"))
                     .WithConnectionStrings(c => c.Map(x => x.MyConnectionString, "someConnectionStringName"))
                     .Populate();

More info in the Wiki

Accepting all kinds of feedback, ideas and/or help :)

konfiggy's People

Contributors

eaardal avatar tonymobster avatar

Stargazers

Yogi avatar

Watchers

 avatar  avatar

Forkers

tonymobster

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.