Class ConfigurationSetBuilderBindingExtensions
Provides startup-time registration and binding helpers for named configuration sets.
Inherited Members
Namespace: Eigenverft.NetLib.Infrastructure.Hosting.Configuration.ConfigurationSets
Assembly: Eigenverft.NetLib.Infrastructure.dll
Syntax
public static class ConfigurationSetBuilderBindingExtensions
Methods
| Edit this page View SourceAddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, Func<string, string>, bool, bool, int, SwitchableJsonRuntimeFailurePolicy)
Registers one switchable JSON source using an arbitrary source path mapping for the set values.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, Func<string, string> sourcePathResolver, bool optional = false, bool reloadOnChange = false, int reloadDelayMilliseconds = 250, SwitchableJsonRuntimeFailurePolicy runtimeFailurePolicy = SwitchableJsonRuntimeFailurePolicy.KeepLastKnownGood)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder receiving the switchable source and binding. |
| string | setName | The already registered configuration-set coordinator name. |
| Func<string, string> | sourcePathResolver | Resolves the complete JSON source path represented by each allowed set value. |
| bool | optional | Whether a missing active source is treated as empty by framework-driven loads. |
| bool | reloadOnChange | Whether the active JSON source is watched independently for physical changes. |
| int | reloadDelayMilliseconds | Debounce delay for active-source file notifications. |
| SwitchableJsonRuntimeFailurePolicy | runtimeFailurePolicy | Runtime failure policy used by the switchable JSON source. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
Remarks
The resolver is evaluated once for every allowed set value during registration and the resulting mapping is frozen. Values may map to directories, differently named files, absolute paths, or even the same source path.
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, SwitchableJsonRegistrationOptions, params string[])
Registers multiple switchable JSON sources in one set directory using internally derived runtime identities and the same source options for every file.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string rootPath, SwitchableJsonRegistrationOptions options, params string[] fileNames)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | |
| string | setName | |
| string | rootPath | |
| SwitchableJsonRegistrationOptions | options | |
| string[] | fileNames |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder |
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, SwitchableJsonRegistrationOptions, params (string SwitchableName, string FileName)[])
Registers and binds multiple independent switchable JSON sources that share the same
{rootPath}/{setValue} directory layout and source options.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string rootPath, SwitchableJsonRegistrationOptions options, params (string SwitchableName, string FileName)[] files)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder receiving all switchable sources and bindings. |
| string | setName | The already registered keyed configuration-set coordinator name. |
| string | rootPath | Root directory containing one subdirectory per allowed set value. |
| SwitchableJsonRegistrationOptions | options | Shared switchable JSON registration options applied to every source. |
| (string SwitchableName, string FileName)[] | files | Pairs of keyed switchable runtime name and JSON file path within each set-value directory. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, string, bool, bool, int, SwitchableJsonRuntimeFailurePolicy)
Registers one switchable JSON source and binds it to a configuration set using an internally derived runtime identity.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string rootPath, string fileName, bool optional = false, bool reloadOnChange = false, int reloadDelayMilliseconds = 250, SwitchableJsonRuntimeFailurePolicy runtimeFailurePolicy = SwitchableJsonRuntimeFailurePolicy.KeepLastKnownGood)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | |
| string | setName | |
| string | rootPath | |
| string | fileName | |
| bool | optional | |
| bool | reloadOnChange | |
| int | reloadDelayMilliseconds | |
| SwitchableJsonRuntimeFailurePolicy | runtimeFailurePolicy |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder |
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, string, string, SwitchableJsonRegistrationOptions)
Registers and binds one switchable JSON source using the complete source options.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string switchableName, string rootPath, string fileName, SwitchableJsonRegistrationOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | |
| string | setName | |
| string | switchableName | |
| string | rootPath | |
| string | fileName | |
| SwitchableJsonRegistrationOptions | options |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder |
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, string, string, bool, bool, int, SwitchableJsonRuntimeFailurePolicy)
Registers one switchable JSON source and binds it to the common directory layout
{rootPath}/{setValue}/{fileName} in one startup call.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string switchableName, string rootPath, string fileName, bool optional = false, bool reloadOnChange = false, int reloadDelayMilliseconds = 250, SwitchableJsonRuntimeFailurePolicy runtimeFailurePolicy = SwitchableJsonRuntimeFailurePolicy.KeepLastKnownGood)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder receiving the switchable source and binding. |
| string | setName | The already registered keyed configuration-set coordinator name. |
| string | switchableName | The keyed switchable JSON runtime name to register. |
| string | rootPath | Root directory containing one subdirectory per allowed set value. |
| string | fileName | JSON file path relative to each set-value directory. |
| bool | optional | Whether a missing active source is treated as empty by framework-driven loads. |
| bool | reloadOnChange | Whether the active JSON source is watched independently for physical changes. |
| int | reloadDelayMilliseconds | Debounce delay for active-source file notifications. |
| SwitchableJsonRuntimeFailurePolicy | runtimeFailurePolicy | Runtime failure policy used by the switchable JSON source. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
Remarks
The initial JSON path is derived from the coordinator's current ActiveValue, so startup code does not repeat that value. If binding fails after registration, the just-created switchable source is removed again so this convenience operation remains all-or-nothing from the builder's perspective.
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, params string[])
Registers multiple switchable JSON sources in one set directory using internally derived runtime identities.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string rootPath, params string[] fileNames)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | |
| string | setName | |
| string | rootPath | |
| string[] | fileNames |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder |
AddSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, params (string SwitchableName, string FileName)[])
Registers and binds multiple independent switchable JSON sources that share the same
{rootPath}/{setValue} directory layout.
Declaration
public static IHostApplicationBuilder AddSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string rootPath, params (string SwitchableName, string FileName)[] files)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder receiving all switchable sources and bindings. |
| string | setName | The already registered keyed configuration-set coordinator name. |
| string | rootPath | Root directory containing one subdirectory per allowed set value. |
| (string SwitchableName, string FileName)[] | files | Pairs of keyed switchable runtime name and JSON file path within each set-value directory. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
Remarks
Every pair remains an independent switchable provider/runtime for loading, active-file watching, LKG and lifecycle observation. Binding does not create a grouped provider, but it does grant this configuration set exclusive ownership of manual source selection for each runtime; direct participant source switches are rejected while the binding exists. All entries are validated before registration begins. If a later registration still fails, already-created entries from this batch are rolled back in reverse order.
BindSwitchableJsonDirectoryToConfigurationSet(IHostApplicationBuilder, string, string, string, string)
Binds a switchable JSON source using the common directory layout {rootPath}/{setValue}/{fileName}.
Declaration
public static IHostApplicationBuilder BindSwitchableJsonDirectoryToConfigurationSet(this IHostApplicationBuilder builder, string setName, string switchableName, string rootPath, string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder containing both registrations. |
| string | setName | The keyed configuration-set coordinator name. |
| string | switchableName | The keyed switchable JSON runtime name. |
| string | rootPath | Root directory containing one subdirectory per allowed set value. |
| string | fileName | JSON file path located inside each set-value directory. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
BindSwitchableJsonToConfigurationSet(IHostApplicationBuilder, string, string, Func<string, string>)
Binds an already registered switchable JSON source to an already registered configuration set before the host is built.
Declaration
public static IHostApplicationBuilder BindSwitchableJsonToConfigurationSet(this IHostApplicationBuilder builder, string setName, string switchableName, Func<string, string> sourcePathResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostApplicationBuilder | builder | The host application builder containing both registrations. |
| string | setName | The keyed configuration-set coordinator name. |
| string | switchableName | The keyed switchable JSON runtime name. |
| Func<string, string> | sourcePathResolver | Resolves the source path represented by each allowed set value. |
Returns
| Type | Description |
|---|---|
| IHostApplicationBuilder | The same builder for chaining. |
Remarks
The coordinator and switchable source may be registered in either order, but both must exist before this method is called. Binding is completed immediately during startup, so no hosted-service timing or post-Build initialization is required. The binding verifies that the switchable source already represents the coordinator's active value.