Oakrey.Applications.Settings
5.1.5
dotnet add package Oakrey.Applications.Settings --version 5.1.5
NuGet\Install-Package Oakrey.Applications.Settings -Version 5.1.5
<PackageReference Include="Oakrey.Applications.Settings" Version="5.1.5" />
<PackageVersion Include="Oakrey.Applications.Settings" Version="5.1.5" />
<PackageReference Include="Oakrey.Applications.Settings" />
paket add Oakrey.Applications.Settings --version 5.1.5
#r "nuget: Oakrey.Applications.Settings, 5.1.5"
#:package Oakrey.Applications.Settings@5.1.5
#addin nuget:?package=Oakrey.Applications.Settings&version=5.1.5
#tool nuget:?package=Oakrey.Applications.Settings&version=5.1.5
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 a one-call DI registration extension.
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 registration - single
ConfigureSettingService(IServiceCollection)call registers all required services. - Logging and tracing - integrated with
Oakrey.LogandOakrey.Telemetry.Tracing.
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)
- Package references:
Oakrey.Log,Oakrey.ViewModels - Project references (when used from source):
Json,Application,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.ConfigureSettingService();
This registers IFileService, IJsonSettingService, and the open-generic ISettingsService<>.
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.ConfigureSettingService();
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.ConfigureSettingService();
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; user-overrides are merged on top.
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.Base (>= 4.0.3)
- Oakrey.Applications.Json (>= 3.0.3)
- Oakrey.Applications.ViewModels (>= 2.0.3)
- Oakrey.Log (>= 2.0.0)
- Oakrey.ViewModels (>= 2.1.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Oakrey.Applications.Settings:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.Log
Integrates Oakrey logging into .NET WPF apps via IServiceCollection extensions: registers a WpfQueueLogger for real-time UI log visualization, a settings-persisted LogViewModel with log-level filtering, and a preloadable log file cleanup service with a 7-day retention policy. |
|
|
Oakrey.Applications.ControlObjects
A .NET WPF library for building interactive, validated control objects. Provides a base class hierarchy for reactive sending objects, enable/disable and timer-driven variants, cancelable async operations, device abstraction, multi-key gesture support, and observable collections with automatic JSON persistence. |
|
|
Oakrey.Applications.FileBrowsing
File browsing and selection management library for .NET applications. Features directory browsing with customizable search patterns, reactive file selection tracking, persistent settings, and WPF data binding support. Includes abstract base classes for creating specialized file browsers. |
GitHub repositories
This package is not used by any popular GitHub repositories.