ConfigurationKeyOptions Class
Definition
- Namespace
- Bodu.Text.Configuration
- Assembly
- Bodu.Text.Configuration.dll
- Package
- Bodu.Text.Configuration 1.3.0
Controls how raw configuration keys are split into segments and mapped to the logical keys 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, or keeps a key whole under Identity, 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 recognized 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, or
a. .b, whose middle segment is whitespace alone). The default rejects empty segments.
Identity does not split a key, so it has no segment to reject.
public bool AllowEmptySegments { get; init; }
Property Value
CaseSensitive
Gets a value indicating whether logical key comparison is case-sensitive.
public bool CaseSensitive { get; init; }
Property Value
Default
Gets the default key options: DotToColon mapping, case-insensitive
comparison, and . / : separators recognized 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.
LowercaseKeys
Gets a value indicating whether the logical key is lowercased with the casing rules of the invariant culture, as EditorConfig lowercases every key after parsing. The default keeps the case each key was written in.
public bool LowercaseKeys { get; init; }
Property Value
Mapping
Gets the mapping that converts the raw key to its configuration key: colon-delimited, or kept as written under Identity.
public ConfigurationKeyMapping Mapping { get; init; }
Property Value
- ConfigurationKeyMapping
The selected ConfigurationKeyMapping value.
SegmentSeparators
Gets the segment-separator characters recognized in a raw key when splitting into segments. Identity does not split a key, so it ignores them.
public IReadOnlyList<char> SegmentSeparators { get; init; }
Property Value
- IReadOnlyList<char>
A non-empty set of separator characters. The default is
{ '.', ':' }.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |