Table of Contents

ConfigurationExtensions Class

Definition

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

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

entry IniEntry

The entry whose key should be transformed.

options ConfigurationKeyOptions

The key options, or null for the defaults.

Returns

string

The colon-delimited configuration path.

Exceptions

ArgumentNullException

entry is 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

document IniDocumentBase

The document to resolve.

targetPath string

The path the resolved view is evaluated for, or null.

Returns

ConfigurationView

A populated ConfigurationView.

Exceptions

ArgumentNullException

document is 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

document IniDocumentBase

The document to resolve.

targetPath string

The path the resolved view is evaluated for, or null.

options ConfigurationResolveOptions

The resolve options, or null for the Bodu defaults.

Returns

ConfigurationView

A populated ConfigurationView.

Exceptions

ArgumentNullException

document is null.

InvalidOperationException

The supplied options require a path root and none was provided.

Applies to

ProductVersions
.NET8, 10