PetToys.TemplatedConfigurationProvider 1.0.0-rc1

Prefix Reserved
This is a prerelease version of PetToys.TemplatedConfigurationProvider.
There is a newer version of this package available.
See the version list below for details.
dotnet add package PetToys.TemplatedConfigurationProvider --version 1.0.0-rc1                
NuGet\Install-Package PetToys.TemplatedConfigurationProvider -Version 1.0.0-rc1                
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.0.0-rc1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PetToys.TemplatedConfigurationProvider --version 1.0.0-rc1                
#r "nuget: PetToys.TemplatedConfigurationProvider, 1.0.0-rc1"                
#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.0.0-rc1&prerelease

// Install PetToys.TemplatedConfigurationProvider as a Cake Tool
#tool nuget:?package=PetToys.TemplatedConfigurationProvider&version=1.0.0-rc1&prerelease                

Templated configuration provider test

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 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 was computed.  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 2,465 4/16/2024
1.1.1 108 4/16/2024
1.1.0 8,881 11/14/2023
1.0.1 1,763 7/10/2023
1.0.0 346 7/4/2023
1.0.0-rc1 142 7/3/2023

- fixed action