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

Version Downloads Last Updated
5.1.5 98 5/15/2026
5.1.4 126 3/13/2026
5.1.0 132 2/13/2026
5.0.1 117 2/11/2026
5.0.0 435 11/18/2025
4.0.1 197 10/31/2025
4.0.0 219 10/22/2025
3.3.1 186 10/10/2025
3.2.0 242 9/29/2025
3.1.0 226 9/23/2025
3.0.0 224 9/8/2025
2.0.0 356 6/9/2025
1.0.0 299 4/17/2025