Skip to content

lawrence-laz/Extensions.Configuration.Object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

29ddfbf · Dec 5, 2023

History

35 Commits
Jul 24, 2023
Jul 25, 2023
Dec 5, 2023
Dec 5, 2023
Oct 13, 2020
Oct 13, 2020
Oct 16, 2020
Nov 6, 2020
Oct 13, 2020

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();

Instead of this:

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();
// appsettings.json
{
    "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.