Oakrey.Applications.Settings
7.0.0
dotnet add package Oakrey.Applications.Settings --version 7.0.0
NuGet\Install-Package Oakrey.Applications.Settings -Version 7.0.0
<PackageReference Include="Oakrey.Applications.Settings" Version="7.0.0" />
<PackageVersion Include="Oakrey.Applications.Settings" Version="7.0.0" />
<PackageReference Include="Oakrey.Applications.Settings" />
paket add Oakrey.Applications.Settings --version 7.0.0
#r "nuget: Oakrey.Applications.Settings, 7.0.0"
#:package Oakrey.Applications.Settings@7.0.0
#addin nuget:?package=Oakrey.Applications.Settings&version=7.0.0
#tool nuget:?package=Oakrey.Applications.Settings&version=7.0.0
Oakrey.Applications.Settings
WPF-only (.NET 10, Windows) library providing persistent and volatile typed key-value settings backed by JSON, bindable SettingsBase view-model integration, automatic CallerMemberName key inference, built-in window-bounds restore, and composition-root DI integration.
Main features
ISettingsService/ISettingsService<T>- typed, generic service for loading, saving and querying settings per settings class.- Persistent and volatile settings - persistent settings survive application restarts; volatile settings are held in memory only for the current session.
SettingsBase- abstract base class deriving fromViewModelBase; combinesISettingsServicewithINotifyPropertyChangedso settings properties bind directly in WPF.CallerMemberNamekey inference -Get<T>()andSet<T>()use the calling property name as the storage key automatically; no magic strings required.RestoreBounds- ready-made settings class that stores and restoresTop,Left,Width,Heightfor aWindow, with sensible minimum-value guards.RestoreBoundExtension-ApplyRestoreBoundsandSaveRestoreBoundsextension methods onSystem.Windows.Window.- JSON backing - settings are serialized to and loaded from JSON via
IJsonSettingService; each settings class occupies its own section keyed by its full type name. - DI integration - explicit registrations keep service lifetimes visible in the composition root.
- Logging and tracing - integrated with
Oakrey.LogandOakrey.Telemetry.Tracing. - Safe persistence - malformed or inaccessible JSON is not silently replaced with defaults.
- Concurrent section updates - read-modify-write operations are serialized per settings file.
Architecture
classDiagram
class ISettingsService {
+Get~TValue~(key) TValue
+GetVolatile~TValue~(key) TValue
+Set~TValue~(value, key)
+SetVolatile~TValue~(value, key)
+Load()
+Save()
+AppSettingPath string
}
class SettingsService~TSetting~ {
-settingsStorage Dictionary
-volatileSettingsStorage Dictionary
-jsonService IJsonSettingService
}
class SettingsBase {
#Get~TValue~(key) TValue
#Set~TValue~(value, key)
#GetVolatile~TValue~(key) TValue
#SetVolatile~TValue~(value, key)
}
class RestoreBounds {
+Top int
+Left int
+Width int
+Height int
}
ISettingsService <|.. SettingsService~TSetting~
SettingsBase --> ISettingsService
RestoreBounds --|> SettingsBase
Requirements
- .NET 10 Windows (WPF)
- Direct packages: Oakrey.Log.Abstractions 3.0.0, Oakrey.Telemetry 2.0.1, and Oakrey.ViewModels 3.0.0.
- Project references (when used from source): Abstractions, Files.Abstractions, Json, and ViewModels.
Installation
NuGet Package Manager
- Open the project in Visual Studio.
- Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
- Search for
Oakrey.Applications.Settingsand install.
.NET CLI
dotnet add package Oakrey.Applications.Settings
Package Manager Console
Install-Package Oakrey.Applications.Settings
Configuration
Register all required services with a single call in your DI setup:
services.AddTransient<IFileService, FileService>();
services.AddTransient<IJsonSettingService, JsonSettingService>();
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
Register the file, JSON section, and open-generic settings services in the application composition root as shown above.
Example usage
Custom settings class
public sealed class AppSettings(ISettingsService<AppSettings> settingsService)
: SettingsBase(settingsService)
{
public string Theme
{
get => Get<string>() ?? "Dark";
set => Set(value);
}
public bool ShowToolbar
{
get => Get<bool>();
set => Set(value);
}
}
Register with DI:
services.AddTransient<IFileService, FileService>();
services.AddTransient<IJsonSettingService, JsonSettingService>();
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
services.AddTransient<AppSettings>();
Window bounds restore
// In Window.Loaded
window.ApplyRestoreBounds(restoreBounds);
// In Window.Closing
window.SaveRestoreBounds(restoreBounds);
Register RestoreBounds in DI (it is resolved via ISettingsService<RestoreBounds>):
services.AddTransient<IFileService, FileService>();
services.AddTransient<IJsonSettingService, JsonSettingService>();
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
services.AddTransient<RestoreBounds>();
Development notes
- Settings are stored per type: the full type name of
TSettingis used as the JSON section key. - Default settings are loaded first and used per key when a user value is missing or has an incompatible type.
SettingsService<T>implementsIDisposable;Dispose()triggers a finalSave().RestoreBoundsenforces a minimum of 100 px for position and 768 px for dimensions.- Volatile settings are not persisted to disk and are cleared on dispose.
Project information
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| Target framework | net10.0-windows |
| NuGet package | Oakrey.Applications.Settings |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/ApplicationServices |
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Oakrey.Applications.Abstractions (>= 7.0.0)
- Oakrey.Applications.Files.Abstractions (>= 7.0.0)
- Oakrey.Applications.Json (>= 7.0.0)
- Oakrey.Applications.ViewModels (>= 7.0.0)
- Oakrey.Log.Abstractions (>= 3.0.0)
- Oakrey.Telemetry (>= 2.0.1)
- Oakrey.ViewModels (>= 3.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Oakrey.Applications.Settings:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.Base
A foundational .NET library for building modular WPF applications. Provides application lifecycle management, MVVM ViewModel resolution, structured logging, telemetry, and sequential or parallel service preloading with full unhandled-exception coverage. |
|
|
Oakrey.Applications.SecureSettings
Readable JSON secured settings service for critical values stored in SecuredSettings.json, with HMAC integrity protection, Windows-user authorization, audit history, and an explicit ISecuredSettingsService API that can run beside regular Settings.json settings. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0 | 121 | 7/20/2026 |
| 6.0.2 | 107 | 7/8/2026 |
| 6.0.1 | 131 | 6/16/2026 |
| 6.0.0 | 121 | 5/22/2026 |
| 5.1.6 | 123 | 5/22/2026 |
| 5.1.5 | 126 | 5/15/2026 |
| 5.1.4 | 144 | 3/13/2026 |
| 5.1.0 | 144 | 2/13/2026 |
| 5.0.1 | 129 | 2/11/2026 |
| 5.0.0 | 445 | 11/18/2025 |
| 4.0.1 | 206 | 10/31/2025 |
| 4.0.0 | 232 | 10/22/2025 |
| 3.3.1 | 197 | 10/10/2025 |
| 3.2.0 | 259 | 9/29/2025 |
| 3.1.0 | 239 | 9/23/2025 |
| 3.0.0 | 235 | 9/8/2025 |
| 2.0.0 | 368 | 6/9/2025 |
| 1.0.0 | 309 | 4/17/2025 |