PetToys.TemplatedConfigurationProvider 1.1.2

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package PetToys.TemplatedConfigurationProvider --version 1.1.2
NuGet\Install-Package PetToys.TemplatedConfigurationProvider -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PetToys.TemplatedConfigurationProvider" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PetToys.TemplatedConfigurationProvider --version 1.1.2
#r "nuget: PetToys.TemplatedConfigurationProvider, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PetToys.TemplatedConfigurationProvider as a Cake Addin
#addin nuget:?package=PetToys.TemplatedConfigurationProvider&version=1.1.2

// Install PetToys.TemplatedConfigurationProvider as a Cake Tool
#tool nuget:?package=PetToys.TemplatedConfigurationProvider&version=1.1.2

Templated configuration provider

Unit Test NuGet Version NuGet Downloads

Features

This library adds its own ConfigurationProvider to the configuration builder. This provider can override values from previously registered providers. New values are computed according to the template (if defined).

  • Absolute references to values are supported.
  • Relative links from the same or parent sections are supported.
  • Configuration reload are supported (IOptionMonitor<>).

Template examples

Configuration:

{
  "ConnectionStrings": {
    "DbConnection1": "Host=localhost;Password={ConnectionStrings:DbConnection:Password};",
    "DbConnection2": "Host=localhost;Password={DbConnection:Password};",
    "DbConnection:Password": "Pa$Sw0{rD"
  }
}

Result:

{
  "ConnectionStrings": {
    "DbConnection1": "Host=localhost;Password=Pa$Sw0{rD;",
    "DbConnection2": "Host=localhost;Password=Pa$Sw0{rD;",
    "DbConnection:Password": "Pa$Sw0{rD"
  }
}

More examples in unit tests.

Getting started

  • Provider is installed from NuGet. dotnet add package PetToys.TemplatedConfigurationProvider
  • Add a using statement to PetToys.TemplatedConfigurationProvider
  • Add a provider to the configuration builder, preferably by using the AddTemplatedConfiguration() extension method.

Examples of using

using PetToys.TemplatedConfigurationProvider;

/* snip ... */

    IConfigurationRoot configuration = new ConfigurationBuilder()
        .AddJsonFile("appsettings.json")
        .AddUserSecrets(Assembly.GetExecutingAssembly())
        .AddEnvironmentVariables()
        .AddTemplatedConfiguration()
        .AddCommandLine(args)
        .Build();
using PetToys.TemplatedConfigurationProvider;

/* snip ... */

    var builder = WebApplication.CreateBuilder(args);
    builder.Configuration.AddTemplatedConfiguration(opt =>
    {
        opt.TemplateCharacterStart = '[';
        opt.TemplateCharacterEnd = ']';
    });

Provided under the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 182 4/16/2024
1.1.1 79 4/16/2024
1.1.0 7,237 11/14/2023
1.0.1 1,733 7/10/2023
1.0.0 319 7/4/2023
1.0.0-rc1 116 7/3/2023