Eigenverft.NetLib.Configuration.SwitchableJson 1.0.0.5

dotnet add package Eigenverft.NetLib.Configuration.SwitchableJson --version 1.0.0.5
                    
NuGet\Install-Package Eigenverft.NetLib.Configuration.SwitchableJson -Version 1.0.0.5
                    
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="Eigenverft.NetLib.Configuration.SwitchableJson" Version="1.0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eigenverft.NetLib.Configuration.SwitchableJson" Version="1.0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Eigenverft.NetLib.Configuration.SwitchableJson" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Eigenverft.NetLib.Configuration.SwitchableJson --version 1.0.0.5
                    
#r "nuget: Eigenverft.NetLib.Configuration.SwitchableJson, 1.0.0.5"
                    
#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.
#:package Eigenverft.NetLib.Configuration.SwitchableJson@1.0.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Eigenverft.NetLib.Configuration.SwitchableJson&version=1.0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Eigenverft.NetLib.Configuration.SwitchableJson&version=1.0.0.5
                    
Install as a Cake Tool

Eigenverft.NetLib.Configuration.SwitchableJson

NuGet Version NuGet Downloads Repository CI Targets License

Register JSON as a normal configuration provider, with an isolated preparation step before publication and a stable runtime handle for deliberate source changes.

✨ At a glance

Package Eigenverft.NetLib.Configuration.SwitchableJson
Registration AddSwitchableJsonFile(...)
Runtime API ISwitchableJsonConfiguration.TrySwitch(...)
Failure behavior Reject failed candidates; keep the active snapshot by default
Optional capabilities File watching, candidate preparation, value protection
Target frameworks .NET 8 and .NET 10
License MIT

📦 Installation

dotnet add package Eigenverft.NetLib.Configuration.SwitchableJson

🚀 Quick start

Create both files with valid JSON before running this example; the initial file is required by default. Resolve a keyed runtime handle from DI after building the host to switch to another file:

using System.IO;
using Eigenverft.NetLib.Configuration.SwitchableJson;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
string settings = Path.Combine(builder.Environment.ContentRootPath, "settings");
string normalPath = Path.Combine(settings, "Operational.Normal.json");
string incidentPath = Path.Combine(settings, "Operational.Incident.json");

builder.AddSwitchableJsonFile(
    name: "OperationalSettings",
    initialPath: normalPath,
    reloadOnChange: true);

using IHost host = builder.Build();
ISwitchableJsonConfiguration source =
    host.Services.GetRequiredKeyedService<ISwitchableJsonConfiguration>(
        "OperationalSettings");

SwitchableJsonSwitchResult result = source.TrySwitch(incidentPath);
if (!result.Succeeded)
{
    // The previous active source and published configuration remain in place.
}

The provider stays at its registered precedence. Changes flow through normal IConfiguration reload behavior when the effective values change.

🧭 Preparation, reload, and protection

An initial path may be absolute or relative to the host content root. Each initial load, file reload, or requested source switch is parsed and prepared as a candidate before the published snapshot changes. A missing, invalid, inaccessible, or rejected candidate leaves the last successful snapshot active. ReloadOnChange is opt-in; the default is false. Manual failures keep the current source by default, or can be configured to throw with SwitchableJsonRuntimeFailurePolicy.Throw.

Set SwitchableJsonRegistrationOptions.CandidatePreparation to an application-defined IJsonConfigurationSourcePreparation or a bundle from JsonConfigurationCandidatePreparations.Compose(...). Preparation steps run in order against an isolated candidate. If several sources must change as one unit, use Eigenverft.NetLib.Configuration.Sets, which builds on this package.

Optional ValueProtection selects JSON key names or full configuration paths and uses codecs from Eigenverft.NetLib.Configuration.Values. Matching plaintext values may be written back in encoded form during registration or later source loads, so the application needs write access when matching clear text is present. Protection is load-bound; it is not a continuous file-watcher invariant. The registered decoder runs before candidate preparation. Codec strength varies: reversible transforms such as Base64 or ROT13 are not cryptographic confidentiality; choose an appropriate codec for the deployment threat model.

The runtime handle exposes LifecycleChanged independently of IConfiguration change tokens. A completed switch or reload can be observable through that event even when the effective key/value snapshot is unchanged. Do not use ordinary file reload as a transaction mechanism across multiple files; use Configuration Sets for that.

🎯 Target frameworks

The package targets net8.0 and net10.0.

📄 License

MIT License

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Eigenverft.NetLib.Configuration.SwitchableJson:

Package Downloads
Eigenverft.NetLib.Configuration.Sets

Coordinated configuration set state, switching, persistence, and hosted services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.5 84 9/29/2026
1.0.0.4 103 9/28/2026
1.0.0.3 114 9/12/2026

Initial capability package extracted from Eigenverft.NetLib.Infrastructure.