ConfigurationExtensions Class
Definition
- Namespace
- Bodu.Text.Configuration
- Assembly
- Bodu.Text.Configuration.dll
- Package
- Bodu.Text.Configuration 1.0.0
Extension methods that layer Bodu Text Configuration behaviour (path-aware resolution and dotted-to-colon key mapping) onto the underlying IniDocumentBase and IniEntry primitives.
public static class ConfigurationExtensions
- Inheritance
-
ConfigurationExtensions
- Inherited Members
Remarks
The Bodu Text Configuration model is intentionally layered on top of its raw INI document primitives rather than replacing them: an IniDocumentBase remains the source-faithful in-memory representation, and these extension methods add the configuration-specific behaviour - target-path resolution and dotted-to-colon key normalization - that turns that raw document into the resolved snapshot consumed by application code.
The primary entry point is Resolve(IniDocumentBase, string?, ConfigurationResolveOptions?), which produces a ConfigurationView for a supplied target path. Pair it with Parse(string) at the start of the pipeline and with the typed accessors on ConfigurationView at its end.
ConfigurationDocument document = ConfigurationDocument.Parse("""
root = true
[*]
indent_size = 4
[src/**.cs]
indent_size = 8
""");
// Sections whose glob matches the target path apply, later sections winning.
ConfigurationView view = document.Resolve("src/App/Program.cs");
var indent = view.GetInt32("indent_size"); // 8
Methods
ConfigurationPath(IniEntry, ConfigurationKeyOptions?)
Computes the colon-delimited configuration path for an entry's raw key using the supplied key options. Mirrors Parse(string, ConfigurationKeyOptions?) and exposes the resulting Path.
public static string ConfigurationPath(this IniEntry entry, ConfigurationKeyOptions? options = null)
Parameters
entryIniEntryThe entry whose key should be transformed.
optionsConfigurationKeyOptionsThe key options, or null for the defaults.
Returns
- string
The colon-delimited configuration path.
Exceptions
- ArgumentNullException
entryis null.
Resolve(IniDocumentBase, string?)
Projects the document into a resolved ConfigurationView for the supplied target path using the default Bodu resolve options.
public static ConfigurationView Resolve(this IniDocumentBase document, string? targetPath = null)
Parameters
documentIniDocumentBaseThe document to resolve.
targetPathstringThe path the resolved view is evaluated for, or null.
Returns
- ConfigurationView
A populated ConfigurationView.
Exceptions
- ArgumentNullException
documentis null.
Resolve(IniDocumentBase, string?, ConfigurationResolveOptions?)
Projects the document into a resolved ConfigurationView for the supplied target path using the supplied options.
public static ConfigurationView Resolve(this IniDocumentBase document, string? targetPath, ConfigurationResolveOptions? options)
Parameters
documentIniDocumentBaseThe document to resolve.
targetPathstringThe path the resolved view is evaluated for, or null.
optionsConfigurationResolveOptionsThe resolve options, or null for the Bodu defaults.
Returns
- ConfigurationView
A populated ConfigurationView.
Exceptions
- ArgumentNullException
documentis null.- InvalidOperationException
The supplied options require a path root and none was provided.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |