Coder Social home page Coder Social logo

configurationextensions's Introduction

Configuration Transformation Classes

ConfigurationExtensions

Is a set of classes allowing to map and transform configuration secitons or values over ConfigurationManager.

Usage

Add using directive and go ahead!

using Zagidziran.ConfigurationExtensions;

var confgiurationManger = new ConfigurationManager();
confgiurationManger.AddYamlFile(@".\sample.yaml");

confgiurationManger.Transform();

When sample.yaml may look like this:

someData:
  someValue: 1

mappedData: $(someData)
mappedValue: $(someData:value1)
constructedValue: Text$(someData:value1)

Advanced Usage

In advanced scenario you may use C# code to define your transformation.

someData:
  someValue: 1

multioledVale: |-
  ${
    var someValue = int.Parse(Configuration["someData:someValue"]);
    return someValue * 17;
  }

NuGet

Nuget package to use is Zagidziran.ConfigurationExtensions. Awailable on nuget.org Zagidziran.ConfigurationExtensions Zagidziran.ConfigurationExtensions

A Few Explanation Words

When you call the Transform() method the code traverses through configuration and replaces entries in the brackets or parentheses with leading dollar sign. Parentheses allows to map a configuration value to another one. When bracers allows to write a C# code returning a dictionary string or null. The text inside the parentheses should point to existing configuration key or you get ReferencedKeyNotFoundException. The delimiter is semicolon. The code may return doctionary. Thereat all dictionary content will be added to configuration with prefix pointing to the code. The only values are transformed, not keys.

configurationextensions's People

Contributors

zagidziran avatar

Watchers

 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.