ConfigurationResolvedEntry Class
Definition
- Namespace
- Bodu.Text.Configuration
- Assembly
- Bodu.Text.Configuration.dll
- Package
- Bodu.Text.Configuration 1.0.0
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
keystringThe canonical configuration key in colon-delimited form.
valuestringThe resolved value, or null when the source value was null.
sourceLocationConfigurationSourceLocationThe position in the source document that supplied the value.
sectionPatternstringThe pattern of the section that supplied the value, or null when the value came from the document preamble (global section).
Exceptions
- ArgumentNullException
keyis null.
Properties
Key
Gets the canonical configuration key (colon-delimited).
public string Key { get; }
Property Value
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
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
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |