Table of Contents

ConfigurationKeyOptions Class

Definition

Namespace
Bodu.Text.Configuration
Assembly
Bodu.Text.Configuration.dll
Package
Bodu.Text.Configuration 1.0.0
Source
ConfigurationKeyOptions.cs

Controls how raw configuration keys are split into segments and mapped to the colon-delimited logical key shape used by the resolved view and the Microsoft.Extensions.Configuration bridge.

public sealed class ConfigurationKeyOptions
Inheritance
ConfigurationKeyOptions
Inherited Members
Extension Methods

Remarks

Two questions need consistent answers for a configuration host: how are the dotted, colon-delimited, or mixed key forms in a source document split into segments, and under which comparer are the resulting keys looked up. ConfigurationKeyOptions answers both - SegmentSeparators drives splitting, Mapping drives the canonical join, and CaseSensitive drives the comparer exposed via KeyComparer and used for equality on every ConfigurationKey it produces.

The same instance is consumed by KeyOptions and KeyOptions; sharing one configured value across both keeps the parsed model and the resolved view's lookups consistent. The default Default mirrors Microsoft.Extensions.Configuration - case-insensitive ordinal comparison, dot-to-colon mapping, and { '.', ':' } as recognised separators.

Instances are immutable once constructed; init-only setters allow object-initializer syntax for callers that need to deviate from the defaults. Reuse a single configured instance across calls when consistency matters.

// Dotted keys normalize to colon-separated configuration paths by default;
// Identity keeps authored keys verbatim.
var options = new ConfigurationResolveOptions
{
    KeyOptions = new ConfigurationKeyOptions { Mapping = ConfigurationKeyMapping.Identity },
};

Constructors

ConfigurationKeyOptions()

public ConfigurationKeyOptions()

Properties

AllowEmptySegments

Gets a value indicating whether the parser permits empty segments in a raw key (for example a..b). The default rejects empty segments.

public bool AllowEmptySegments { get; init; }

Property Value

bool

true when empty segments are allowed; otherwise, false.

CaseSensitive

Gets a value indicating whether logical key comparison is case-sensitive.

public bool CaseSensitive { get; init; }

Property Value

bool

true when keys are compared with ordinal case sensitivity; otherwise, false. The default is false, mirroring Microsoft.Extensions.Configuration.

Default

Gets the default key options: DotToColon mapping, case-insensitive comparison, and . / : separators recognised by parser input.

public static ConfigurationKeyOptions Default { get; }

Property Value

ConfigurationKeyOptions

A cached default options instance.

KeyComparer

Gets the StringComparer implied by CaseSensitive.

public StringComparer KeyComparer { get; }

Property Value

StringComparer

Ordinal when case-sensitive; otherwise, OrdinalIgnoreCase.

Mapping

Gets the mapping that converts the raw key to a colon-delimited configuration key.

public ConfigurationKeyMapping Mapping { get; init; }

Property Value

ConfigurationKeyMapping

The selected ConfigurationKeyMapping value.

SegmentSeparators

Gets the segment-separator characters recognised in a raw key when splitting into segments.

public IReadOnlyList<char> SegmentSeparators { get; init; }

Property Value

IReadOnlyList<char>

A non-empty set of separator characters. The default is { '.', ':' }.

Applies to

ProductVersions
.NET8, 10