Table of Contents

ConfigurationResolvedEntry Class

Definition

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

Carries the origin metadata for a single key/value pair in a ConfigurationView - which section "won" for the key, which line of which file supplied the value, and the resolved key path itself.

public sealed class ConfigurationResolvedEntry
Inheritance
ConfigurationResolvedEntry
Inherited Members
Extension Methods

Examples

ConfigurationView view = doc.Resolve("src/Foo.cs");
ConfigurationResolvedEntry? entry = view.GetEntry("format:indent:size");
if (entry is not null)
{
    Console.WriteLine($"{entry.Key} = {entry.Value}");
    Console.WriteLine($"  from section: {entry.SectionPattern ?? "<preamble>"}");
    Console.WriteLine($"  at: {entry.SourceLocation}");
}

Remarks

Resolved entries are the debugging surface for layered configuration: when a host has loaded several matching sections and a preamble, and a key resolves to an unexpected value, the entry's SectionPattern identifies the section that won under last-wins precedence and SourceLocation points back to the originating line.

The values exposed here are a snapshot of the resolved view. Mutation of the originating document after resolution does not propagate into existing entries.

Constructors

ConfigurationResolvedEntry(string, string?, ConfigurationSourceLocation, string?)

Initializes a new instance of the ConfigurationResolvedEntry class.

public ConfigurationResolvedEntry(string key, string? value, ConfigurationSourceLocation sourceLocation, string? sectionPattern)

Parameters

key string

The canonical configuration key in colon-delimited form.

value string

The resolved value, or null when the source value was null.

sourceLocation ConfigurationSourceLocation

The position in the source document that supplied the value.

sectionPattern string

The pattern of the section that supplied the value, or null when the value came from the document preamble (global section).

Exceptions

ArgumentNullException

key is null.

Properties

Key

Gets the canonical configuration key (colon-delimited).

public string Key { get; }

Property Value

string

The key as it appears in Values.

SectionPattern

Gets the pattern of the section that supplied the value, or null when the value came from the document preamble (global section).

public string? SectionPattern { get; }

Property Value

string

The section pattern (e.g. *.cs), or null for preamble entries.

SourceLocation

Gets the position in the source document that supplied the value.

public ConfigurationSourceLocation SourceLocation { get; }

Property Value

ConfigurationSourceLocation

The source location. Only the LineNumber is reliably populated - line position and length are approximate and the document path is propagated only when the document was loaded from a file.

Value

Gets the resolved value for Key.

public string? Value { get; }

Property Value

string

The value, or null when the source value was null.

Applies to

ProductVersions
.NET8, 10