Raycynix.Extensions.Configuration 0.2.1

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

Raycynix.Extensions.Configuration

TeamCity build status

Raycynix.Extensions.Configuration contains the core typed-configuration registration helpers for Raycynix applications.

What it contains

  • AddRaycynixEnvironment()
  • AddRaycynixEnvironment(string)
  • AddRaycynixConfigurationSources(...)
  • UseRaycynixConfigurationSources(...)
  • AddRaycynixFeatureFlags(...)
  • AddRaycynixConfiguration<TOptions>(...)
  • AddRaycynixConfigurationAccessor<TOptions>()
  • AddRaycynixConfigurationValidator<TOptions, TValidator>()
  • AddRaycynixConfigurationValidator<TOptions>(...)
  • AddRaycynixConfigurationReloadPolicy<TOptions, TReloadPolicy>()
  • AddRaycynixConfigurationReloadPolicy<TOptions>(...)
  • AddRaycynixConfigurationChangeHandler<TOptions, THandler>()
  • AddRaycynixConfigurationChangeHandler<TOptions>(...)
  • typed configuration binding based on the standard Options pipeline
  • standard environment abstraction based on IHostEnvironment
  • standard configuration source ordering
  • feature flag access through IFeatureFlagAccessor
  • support for default values through delegates and IConfigurationDefaults<TOptions>
  • startup validation through standard IValidateOptions<TOptions> integration
  • unified typed access through IConfigurationAccessor<TOptions>
  • reload governance through IConfigurationReloadPolicy<TOptions>
  • typed change notifications through IOptionsMonitor<TOptions>

What it does not contain

  • custom replacement for IConfiguration
  • custom configuration providers
  • feature flag infrastructure

Usage

builder.Configuration.UseRaycynixConfigurationSources(options =>
{
    options.BaseFileName = "appsettings";
    options.EnvironmentName = builder.Environment.EnvironmentName;
    options.IncludeUserSecrets = builder.Environment.IsDevelopment();
});

builder.Services.AddRaycynixEnvironment();
builder.Services.AddRaycynixFeatureFlags(builder.Configuration);

builder.Services.AddRaycynixConfiguration<MyOptions>(
    builder.Configuration,
    configureDefaults: options =>
    {
        options.TimeoutSeconds = 30;
    });

builder.Services.AddRaycynixConfigurationValidator<MyOptions, MyOptionsValidator>();

builder.Services.AddRaycynixConfigurationReloadPolicy<MyOptions>(context =>
{
    return ConfigurationReloadResult.Reject("MyOptions cannot be changed at runtime.");
});

builder.Services.AddRaycynixConfigurationChangeHandler<MyOptions>(
    static (context, cancellationToken) =>
    {
        Console.WriteLine($"Configuration changed: {context.ChangedAtUtc:O}");
        return ValueTask.CompletedTask;
    });

Applying Runtime Reload Rules

Use runtime change handling in this order:

  1. register the typed options model with AddRaycynixConfiguration<TOptions>(...)
  2. register a validator if the options must be valid on startup
  3. register a reload policy if runtime updates must be limited
  4. register one or more change handlers for the updates that are actually allowed

Example:

builder.Services.AddRaycynixConfiguration<CacheOptions>(builder.Configuration);

builder.Services.AddRaycynixConfigurationReloadPolicy<CacheOptions>(context =>
{
    if (context.Previous.ConnectionString != context.Current.ConnectionString)
    {
        return ConfigurationReloadResult.Reject(
            "CacheOptions.ConnectionString cannot be changed at runtime.");
    }

    return ConfigurationReloadResult.Apply();
});

builder.Services.AddRaycynixConfigurationChangeHandler<CacheOptions>(
    static (context, cancellationToken) =>
    {
        Console.WriteLine(
            $"Cache options reloaded at {context.ChangedAtUtc:O}. New TTL: {context.Current.DefaultTtlSeconds}");

        return ValueTask.CompletedTask;
    });

In this example:

  • the options are still reloadable
  • connection string changes are rejected
  • allowed changes continue to flow through the registered handlers

By default, the package binds the section named after the options type, for example MyOptions.

You can override the section name explicitly when needed.

Registered validators run through the standard Options validation pipeline and are enforced on startup through ValidateOnStart().

AddRaycynixConfiguration<TOptions>(...) also registers IConfigurationAccessor<TOptions> so application services can read the current typed configuration without directly depending on IOptionsMonitor<TOptions>.

Example:

public class MyService(IConfigurationAccessor<MyOptions> configurationAccessor)
{
    public void Execute()
    {
        var options = configurationAccessor.Current;
        Console.WriteLine(options.TimeoutSeconds);
    }
}

Reload policies are evaluated before change handlers are notified. A policy can apply or reject a runtime change.

When a runtime change is rejected, IConfigurationAccessor<TOptions> continues to expose the last approved configuration snapshot.

Configuration change handlers are triggered through the standard IOptionsMonitor<TOptions> pipeline when reloadable sources produce updated option values.

You can also declare simple runtime reload rules directly on properties:

public class CacheOptions
{
    [ConfigurationReloadBehavior(ConfigurationReloadBehavior.Reject)]
    public string ConnectionString { get; set; } = string.Empty;

    public int DefaultTtlSeconds { get; set; }
}

When a property marked with Reject changes, the runtime update is rejected automatically before handlers are called.

Feature Flags

Use the standard FeatureFlags section to store boolean feature toggles:

{
  "FeatureFlags": {
    "Flags": {
      "NewDashboard": true,
      "UseFastCache": false
    }
  }
}

Register the feature flags accessor:

builder.Services.AddRaycynixFeatureFlags(builder.Configuration);

Use it in application code:

public class DashboardService(IFeatureFlagAccessor featureFlags)
{
    public bool UseNewDashboard()
    {
        return featureFlags.IsEnabled("NewDashboard");
    }
}

Feature flags use the same configuration pipeline as the rest of the package, so they can also participate in reloadable sources.

The standard source order is:

  1. appsettings.json
  2. appsettings.{Environment}.json
  3. user secrets when enabled
  4. environment variables
  5. command-line arguments

The standard environment names are:

  • Development
  • Testing
  • Staging
  • Production
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 (6)

Showing the top 5 NuGet packages that depend on Raycynix.Extensions.Configuration:

Package Downloads
Raycynix.Extensions.Messaging

Transport-agnostic messaging registration, dispatch, direct requests, observability, scoped envelope factories, and outbox/inbox reliability foundations for Raycynix applications.

Raycynix.Extensions.Logging

Structured logging registration, Serilog-based host integration, typed logger adapters, and configurable console or Elasticsearch logging for Raycynix applications.

Raycynix.Extensions.Database

Core shared database registration, DatabaseContext infrastructure, model assembly discovery, explicit provider-package composition, and provider-agnostic EF Core model caching for Raycynix applications.

Raycynix.Extensions.Configuration.AspNetCore

ASP.NET Core integrations for Raycynix configuration source setup, application environment registration, and feature gating.

Raycynix.Extensions.Metrics

Core metrics registration, Prometheus-backed metric services, typed metrics configuration, and application-level instrumentation composition for Raycynix applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 48 4/8/2026
0.2.1 40 4/8/2026