PetToys.TemplatedConfigurationProvider
1.2.0
Prefix Reserved
dotnet add package PetToys.TemplatedConfigurationProvider --version 1.2.0
NuGet\Install-Package PetToys.TemplatedConfigurationProvider -Version 1.2.0
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.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PetToys.TemplatedConfigurationProvider --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PetToys.TemplatedConfigurationProvider, 1.2.0"
#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.2.0 // Install PetToys.TemplatedConfigurationProvider as a Cake Tool #tool nuget:?package=PetToys.TemplatedConfigurationProvider&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Templated configuration provider
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.Extensions.Configuration (>= 7.0.0)
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- added support net9
- some improvements
- out of support net6