Eigenverft.NetLib.Configuration.WritebackJson
1.0.0.5-g17613f8942
See the version list below for details.
dotnet add package Eigenverft.NetLib.Configuration.WritebackJson --version 1.0.0.5-g17613f8942
NuGet\Install-Package Eigenverft.NetLib.Configuration.WritebackJson -Version 1.0.0.5-g17613f8942
<PackageReference Include="Eigenverft.NetLib.Configuration.WritebackJson" Version="1.0.0.5-g17613f8942" />
<PackageVersion Include="Eigenverft.NetLib.Configuration.WritebackJson" Version="1.0.0.5-g17613f8942" />
<PackageReference Include="Eigenverft.NetLib.Configuration.WritebackJson" />
paket add Eigenverft.NetLib.Configuration.WritebackJson --version 1.0.0.5-g17613f8942
#r "nuget: Eigenverft.NetLib.Configuration.WritebackJson, 1.0.0.5-g17613f8942"
#:package Eigenverft.NetLib.Configuration.WritebackJson@1.0.0.5-g17613f8942
#addin nuget:?package=Eigenverft.NetLib.Configuration.WritebackJson&version=1.0.0.5-g17613f8942&prerelease
#tool nuget:?package=Eigenverft.NetLib.Configuration.WritebackJson&version=1.0.0.5-g17613f8942&prerelease
Eigenverft.NetLib.Configuration.WritebackJson
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.
Currentis the file-backed branch. UseMutateCurrentAndSave(...)to persist changes.RuntimeWorkingCopyis detached in-memory state. UseMutateRuntimeWorkingCopy(...); this never writes the backing file.CurrentChangedandRuntimeWorkingCopyChangedreport changes from store operations. Passnotify: falseto 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.0net10.0
A .NET 9 consumer can use the compatible net8.0 asset.
🔗 Project links
📄 License
| Product | Versions 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. |
-
net10.0
-
net8.0
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.