VolocyNazad.ValueStore
1.0.1
dotnet add package VolocyNazad.ValueStore --version 1.0.1
NuGet\Install-Package VolocyNazad.ValueStore -Version 1.0.1
<PackageReference Include="VolocyNazad.ValueStore" Version="1.0.1" />
<PackageVersion Include="VolocyNazad.ValueStore" Version="1.0.1" />
<PackageReference Include="VolocyNazad.ValueStore" />
paket add VolocyNazad.ValueStore --version 1.0.1
#r "nuget: VolocyNazad.ValueStore, 1.0.1"
#:package VolocyNazad.ValueStore@1.0.1
#addin nuget:?package=VolocyNazad.ValueStore&version=1.0.1
#tool nuget:?package=VolocyNazad.ValueStore&version=1.0.1
Toolkit.ValueStore
A file-backed DI settings store with YAML serialization and change notifications.
Toolkit.ValueStore — a service for storing typed settings in a file (YAML by default), with atomic writes, optional tracking of external file changes, and subscriber notifications. Does not depend on the Revit API — despite its origin (extracted from revit.linter), it's a regular .NET library suitable for any application.
Features
IValueStore<T>—CurrentValue,Update(Action<T> change),OnChange(Action<T> listener).- Persistence to a file (the default serializer is
YamlValueStoreSerializer, swappable viaIValueStoreSerializer). - Atomic writes (temp file +
File.Replace) and resilience to a temporarily locked file (retry with a pause). - Optional tracking of external file changes (
FileSystemWatcher+ polling) with subscriber notification viaOnChange. IValueStoreNotificationSource.OnLoadFailed— notifications about load/deserialization errors, replaying the last error to new subscribers.- The file name is configurable via
[StoreFile("name.yml")]on the settings class, or viaValueStoreOptions.FileNameFactory. - One-line DI registration:
AddValueStore(...)/AddValueStore<TSerializer>(...).
Installation
dotnet add package VolocyNazad.ValueStore
Usage
DI registration:
using Microsoft.Extensions.DependencyInjection;
using Toolkit.ValueStore.DI;
using Toolkit.ValueStore.Serialization;
services.AddValueStore<YamlValueStoreSerializer>(options =>
{
options.DirectoryPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"MyApp");
options.WatchForExternalChanges = true;
});
Settings and usage:
using Toolkit.ValueStore.Abstractions;
[StoreFile("my-settings.yml")]
public sealed class MySettings
{
public bool IsEnabled { get; set; }
}
public sealed class MyService(IValueStore<MySettings> store)
{
public void Toggle() => store.Update(s => s.IsEnabled = !s.IsEnabled);
}
Handling file load errors (e.g. malformed YAML):
using Toolkit.ValueStore.Abstractions;
public sealed class SettingsErrorNotifier(IValueStoreNotificationSource source) : IDisposable
{
private readonly IDisposable _subscription = source.OnLoadFailed(args =>
Console.WriteLine($"Failed to load {args.FilePath}: {args.Exception.Message}"));
public void Dispose() => _subscription.Dispose();
}
Requirements
- .NET SDK 10.0.103+ (see
global.json) net48ornet8.0-windows
License
MIT, see LICENSE.md.
Development documentation
Contributing
Read CONTRIBUTING.md before submitting changes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
- YamlDotNet (>= 18.1.0)
-
net8.0-windows7.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
- YamlDotNet (>= 18.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.