Eigenverft.NetLib.Configuration.WritebackJson 1.0.0.5-gdfdd996480

This is a prerelease version of Eigenverft.NetLib.Configuration.WritebackJson.
dotnet add package Eigenverft.NetLib.Configuration.WritebackJson --version 1.0.0.5-gdfdd996480
                    
NuGet\Install-Package Eigenverft.NetLib.Configuration.WritebackJson -Version 1.0.0.5-gdfdd996480
                    
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.WritebackJson" Version="1.0.0.5-gdfdd996480" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eigenverft.NetLib.Configuration.WritebackJson" Version="1.0.0.5-gdfdd996480" />
                    
Directory.Packages.props
<PackageReference Include="Eigenverft.NetLib.Configuration.WritebackJson" />
                    
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.WritebackJson --version 1.0.0.5-gdfdd996480
                    
#r "nuget: Eigenverft.NetLib.Configuration.WritebackJson, 1.0.0.5-gdfdd996480"
                    
#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.WritebackJson@1.0.0.5-gdfdd996480
                    
#: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.WritebackJson&version=1.0.0.5-gdfdd996480&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Eigenverft.NetLib.Configuration.WritebackJson&version=1.0.0.5-gdfdd996480&prerelease
                    
Install as a Cake Tool

Eigenverft.NetLib.Configuration.WritebackJson

NuGet Version NuGet Downloads Repository CI Targets License

Manage a typed JSON document with a persisted branch, an initial rollback snapshot, and a separate runtime-only working copy.

✨ At a glance

Capability What it does Starting point
Persisted state Mutate the current document and save it to JSON MutateCurrentAndSave(...)
Runtime state Keep a detached working copy for unpersisted changes MutateRuntimeWorkingCopy(...)
Startup baseline Retain the original document for explicit rollback InitialSnapshot and restore methods
External edits Optionally watch and reload the backing file watchForExternalChanges
Dependency injection Register a typed store as a singleton AddWritebackJsonStore<T>(...)

📦 Installation

dotnet add package Eigenverft.NetLib.Configuration.WritebackJson

🚀 Quick start

The model must be a reference type with a public parameterless constructor:

using Eigenverft.NetLib.Configuration.WritebackJson;

using var store = new WritebackJsonStore<RuntimeSettings>(
    "AppSettings/runtime-settings.json");

store.MutateRuntimeWorkingCopy(settings => settings.Route = "Preview");
store.MutateCurrentAndSave(settings => settings.Route = "Failover");

public sealed class RuntimeSettings
{
    public string Route { get; set; } = "Primary";
}

The runtime copy remains Preview; changing persisted Current does not overwrite it. Call RestoreRuntimeWorkingCopyFromCurrent() when the runtime branch should resynchronize with the file-backed state.

🧭 State and notifications

At construction, the store loads the JSON document or creates one from new T() if the file is absent. It writes the initial document and captures it as InitialSnapshot. The snapshot is a deep copy and remains the rollback baseline for the lifetime of that store.

  • Current is the file-backed branch. Use MutateCurrentAndSave(...) to persist changes.
  • RuntimeWorkingCopy is detached in-memory state. Use MutateRuntimeWorkingCopy(...); this never writes the backing file.
  • CurrentChanged and RuntimeWorkingCopyChanged report changes from store operations. Pass notify: false to suppress an operation's notification.
  • GetCurrentSnapshot() returns an independent copy of the current state.

Treat the objects returned by Current and RuntimeWorkingCopy as read-only. Directly changing their properties bypasses persistence and change notifications.

👀 External changes and DI

External-file watching is enabled by default. Successfully reloaded content updates Current; it does not replace InitialSnapshot or RuntimeWorkingCopy. Handle ErrorOccurred for background file-system or reload errors. Dispose the store when its lifetime ends.

To register it in a host's service collection:

using Eigenverft.NetLib.Configuration.WritebackJson;
builder.Services.AddWritebackJsonStore<RuntimeSettings>(
    "AppSettings/runtime-settings.json",
    watchForExternalChanges: true);

The store is not an IConfiguration provider and does not publish configuration reload tokens. It can share a file with a JSON configuration provider or SwitchableJson; configure that provider's reload behavior separately if it should observe writes.

🎯 Target frameworks

  • net8.0
  • net10.0

A .NET 9 consumer can use the compatible net8.0 asset.

📄 License

MIT

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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.5-gdfdd996480 0 9/29/2026
1.0.0.5-g17613f8942 0 9/29/2026
1.0.0.3-g28e841270d 0 9/28/2026
1.0.0.2-gbac57d8b97 0 9/11/2026
1.0.0.2-g9537b96514 0 9/11/2026

Initial capability package extracted from Eigenverft.NetLib.Infrastructure.