Oakrey.Applications.Settings 6.0.0

dotnet add package Oakrey.Applications.Settings --version 6.0.0
                    
NuGet\Install-Package Oakrey.Applications.Settings -Version 6.0.0
                    
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="Oakrey.Applications.Settings" Version="6.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Settings" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Settings" />
                    
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 Oakrey.Applications.Settings --version 6.0.0
                    
#r "nuget: Oakrey.Applications.Settings, 6.0.0"
                    
#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 Oakrey.Applications.Settings@6.0.0
                    
#: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=Oakrey.Applications.Settings&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Settings&version=6.0.0
                    
Install as a Cake Tool

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 from ViewModelBase; combines ISettingsService with INotifyPropertyChanged so settings properties bind directly in WPF.
  • CallerMemberName key inference - Get<T>() and Set<T>() use the calling property name as the storage key automatically; no magic strings required.
  • RestoreBounds - ready-made settings class that stores and restores Top, Left, Width, Height for a Window, with sensible minimum-value guards.
  • RestoreBoundExtension - ApplyRestoreBounds and SaveRestoreBounds extension methods on System.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.Log and Oakrey.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

  1. Open the project in Visual Studio.
  2. Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  3. Search for Oakrey.Applications.Settings and 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 TSetting is used as the JSON section key.
  • Default settings are loaded first; user-overrides are merged on top.
  • SettingsService<T> implements IDisposable; Dispose() triggers a final Save().
  • RestoreBounds enforces 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 Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 104 5/22/2026
5.1.6 106 5/22/2026
5.1.5 106 5/15/2026
5.1.4 132 3/13/2026
5.1.0 134 2/13/2026
5.0.1 120 2/11/2026
5.0.0 438 11/18/2025
4.0.1 199 10/31/2025
4.0.0 225 10/22/2025
3.3.1 188 10/10/2025
3.2.0 246 9/29/2025
3.1.0 229 9/23/2025
3.0.0 226 9/8/2025
2.0.0 359 6/9/2025
1.0.0 304 4/17/2025