Skip to content

nicolaspierre1990/Extensions.Configuration.Object

 
 

Repository files navigation

Extensions.Configuration.Object Logo

NuGet Version NuGet Downloads Build

What does this package do?

It allows to load nested configuration from objects instead of loading from JSON or other methods. This is useful in the context of automated tests as the configuration can be defined inside the test itself instead of having multiple JSON files.

In other words you can do this:

var configuration = new ConfigurationBuilder()
    .AddObject(new
    {
        MyProperty = "MyValue",
        MySection = new 
        {
            MyOtherProperty = "MyOtherValue"
        }
    })
    .Build();

Or with a root key

var configuration = new ConfigurationBuilder()
    .AddObject(new
    {
        MyProperty = "MyValue",
        MySection = new 
        {
            MyOtherProperty = "MyOtherValue"
        }
    }, "MyRootKey")
    .Build();

Instead of this:

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

Without RootKey

// appsettings.json
{
    "MyProperty": "MyValue",
    "MySection": { 
        "MyOtherProperty": "MyOtherValue"
    }
}

With RootKey

// appsettings.json
{
    "MyRootKey": {
        "MyProperty": "MyValue",
        "MySection": { 
            "MyOtherProperty": "MyOtherValue"
        }
    }
}

How to get started?

Download from nuget.org:

PS> Install-Package Extensions.Configuration.Object

Look for examples in test project.

About

A simple way to do configuration using POCO objects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%