Class SwitchableJsonConfigurationExtensions
Registers switchable JSON configuration sources and their runtime control handles.
Inherited Members
Namespace: Eigenverft.NetLib.Infrastructure.Hosting.Configuration.SwitchableJson
Assembly: Eigenverft.NetLib.Infrastructure.dll
Syntax
public static class SwitchableJsonConfigurationExtensions
Methods
| Edit this page View SourceAddSwitchableJsonFile(IHostApplicationBuilder, string, string, SwitchableJsonRegistrationOptions)
Adds one switchable JSON source with the complete registration options, including ordered candidate source preparations.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonFile(this IHostApplicationBuilder builder, string name, string initialPath, SwitchableJsonRegistrationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | |
| string | name | |
| string | initialPath | |
| SwitchableJsonRegistrationOptions | options |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder |
AddSwitchableJsonFile(IHostApplicationBuilder, string, string, bool, bool, int, SwitchableJsonRuntimeFailurePolicy)
Adds one JSON configuration source that can later switch to another JSON file through keyed dependency injection.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonFile(this IHostApplicationBuilder builder, string name, string initialPath, bool optional = false, bool reloadOnChange = false, int reloadDelayMilliseconds = 250, SwitchableJsonRuntimeFailurePolicy runtimeFailurePolicy = SwitchableJsonRuntimeFailurePolicy.KeepLastKnownGood)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder receiving both the configuration source and runtime handle. |
| string | name | Caller-defined provider identity and keyed-service key. |
| string | initialPath | Initial JSON path, absolute or relative to the host content root. |
| bool | optional | Whether a missing source is treated as empty during framework-driven provider loads, including the initial load and explicit Reload() operations. |
| bool | reloadOnChange | Whether the currently active source is watched for physical file changes after initial load and after each successful switch. |
| int | reloadDelayMilliseconds | Debounce delay applied to physical file notifications before the active source is prepared again. The default mirrors the conventional Microsoft file-configuration reload delay. |
| SwitchableJsonRuntimeFailurePolicy | runtimeFailurePolicy | How failed manual runtime candidate loads are reported after the host is running. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
Remarks
The registration is deliberately on IHostApplicationBuilder rather than only IConfigurationBuilder because one operation must add an IConfiguration source and a DI runtime handle. A split configuration/service registration API is possible, but would make it easier to accidentally register only one half. The provider identity is otherwise completely agnostic and carries no profile, environment, or directory semantics. File watching is opt-in and independent from manual source switching.
The keyed DI object is a stable runtime handle, not the concrete IConfigurationProvider instance. ConfigurationManager may rebuild concrete providers when its Sources collection changes; the source creates a fresh provider for every Build while the runtime handle preserves the selected source, watcher and lifecycle subscriptions.