Git Product home page Git Product logo

dynamicsettings's Introduction

Dynamic Settings

Dynamic Settings is a .NET library that allows you to load application settings from a variety of sources including environment variables, ConfigurationManager, text files, YAML files, and Redis.

Install

Binaries are available on Nuget at https://www.nuget.org/DynamicSettings

To install, run the following command in the Package Manager Console

PM> Install-Package DynamicSettings

Usage

You can set up your DI container to cascade through the different types of settings as follows. This example uses Autofac, but others will be similar.

var builder = new ContainerBuilder();
builder.Register(c => new AppSettings(new EnvironmentVariableSettings("MYAPP_"), new FileSettings(".", "*.key"), new YamlSettings("Config.yaml"), new ConfigurationManagerSettings())).SingleInstance();

When a setting is accessed through the AppSettings class, this will first look in the EnvironmentVariableSettings, if the setting isn't there, it will then look in FileSettings, then YamlSettings, etc.

Inject an instance of AppSettings and access your configuration settings through it.

public class MyClass
{
	private dynamic _appSettings

    public MyClass(AppSettings settings)
    {
        _appSettings = settings;
    }

    public GetMySetting()
    {
        var setting = _appSettings.MySetting

        return setting;
    }
}

dynamicsettings's People

Contributors

steelheaddigital avatar

Watchers

Hruday avatar

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.