maple-Configuration.OptionsUpdateable 0.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package maple-Configuration.OptionsUpdateable --version 0.1.4
                    
NuGet\Install-Package maple-Configuration.OptionsUpdateable -Version 0.1.4
                    
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="maple-Configuration.OptionsUpdateable" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="maple-Configuration.OptionsUpdateable" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="maple-Configuration.OptionsUpdateable" />
                    
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 maple-Configuration.OptionsUpdateable --version 0.1.4
                    
#r "nuget: maple-Configuration.OptionsUpdateable, 0.1.4"
                    
#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 maple-Configuration.OptionsUpdateable@0.1.4
                    
#: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=maple-Configuration.OptionsUpdateable&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=maple-Configuration.OptionsUpdateable&version=0.1.4
                    
Install as a Cake Tool

Configuration.OptionsUpdateable

.NET Tests

The Configuration.OptionsUpdateable namespace provides a set of classes and interfaces that facilitate the management and updating of configuration options in a flexible and dynamic manner. This namespace is designed to help developers easily modify configuration settings at runtime without requiring application restarts.

Code Coverage

Code coverage for Configuration.OptionsUpdateable is automatically collected with each build:

  • Pull Requests: Coverage summary and badge are posted as PR comments
  • Workflow Runs: View coverage details in the workflow run summary on the Actions tab
  • Detailed Reports: Download the full HTML coverage report from workflow artifacts

Key Features

  • Dynamic Updates: Allows for real-time updates to configuration options, enabling applications to adapt to changing requirements without downtime.

  • Type Safety: Utilizes strong typing to ensure that configuration options are valid and consistent throughout the application.

  • Validation Support: Integrates with validation mechanisms to ensure that updated configuration options meet predefined criteria. Functionality is based on FluentValidation library

Usage

To use the Configuration.OptionsUpdateable namespace, you typically start by defining your configuration options as a class. You can then register this class with the dependency injection container and use the provided interfaces to update the options as needed.

Working example can be found here:

using System;
using Configuration.OptionsUpdateable;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

// ===========================================================
// Define your configuration options class
public class MyConfigOptions : IConfigModel<MyConfigOptions>
{
    public string SettingA { get; set; }
    public int SettingB { get; set; }

    public Position DeepClone()
    {
        // Create a deep copy of the current instance
        // This is a simple example; for complex objects, ensure all nested objects are also cloned
        return this with { };
    }
}

// ===========================================================
// Register the options in the service collection
string configFolder = Path.Combine( System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "MyApp/Config");
builder.ConfigureUpdateableOptions(new UpdateableOptionsConfig
{
    ConfigurationFolder = configFolder,
    ValidateAtStartup = true,
    Validators = 
    [
        new PositionValidator()
    ]
});

// ==============================================================
// catch InvalidConfigurationException and ValidationException 
// during startup to report which configuration file is invalid
// ==============================================================

// ===========================================================
// Inject IUpdateableOptions to update options at runtime
public class MyService
{
    private readonly IUpdateableOptions<MyConfigOptions> _updateableOptions;
    public MyService(IUpdateableOptions<MyConfigOptions> updateableOptions)
    {
        _updateableOptions = updateableOptions;

        // _updateableOptions.Value returns updated information when callback is invoked
        // (information is also updated without registering a callback)
        _updateableOptions.RegisterUpdateNotification((updated) =>
        {
            Console.WriteLine($"Updated Position: {updated}");
            HasReceivedUpdate = true;
        });
    }

    public void UpdateSettings(string newSettingA, int newSettingB)
    {
        // local copy that can be modified
        var options = _updateableOptions.Value;
        
        // Update the settings
        options.SettingA = newSettingA;
        options.SettingB = newSettingB;
        
        // modifications are updated in the underlying storage
        _updateableOptions.Update(options);
    }
}

Config Collection Extensions

Microsoft.Extensions.Configuration namespace is extended with extension methods for updating and inspecting string collection sections within an IConfiguration instance.

These methods allow updating section that represent collections (arrays or lists), and provide utilities for outputting configuration data for debugging or inspection purposes.

The extensions are intended for use with configuration providers that support indexed collection patterns!

Examples:

stringh[] values = [ "NewValue1", "NewValue2", "NewValue3", "NewValue4", "NewValue5" ];

configuration.UpdateStringCollection("TestSection", values);

// Output the contents of the "TestSection"
configuration.DumpSection("TestSection");
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.5 94 5/4/2026
0.1.4 100 4/25/2026
0.1.3 98 4/17/2026
0.1.2 227 12/22/2025
0.1.1 177 12/21/2025
0.1.0 175 12/21/2025