TextConfigurationSource Class
Definition
- Namespace
- Bodu.Extensions.Configuration.Text
- Assembly
- Bodu.Extensions.Configuration.Text.dll
- Package
- Bodu.Extensions.Configuration.Text 1.3.0
A FileConfigurationSource that reads a Bodu Text Configuration file and projects its resolved view into the IConfiguration hierarchy as colon-delimited keys.
public sealed class TextConfigurationSource : FileConfigurationSource, IConfigurationSource
- Inheritance
-
TextConfigurationSource
- Implements
- Inherited Members
- Extension Methods
Examples
// Typical lambda registration via the IConfigurationBuilder extension.
builder.Configuration.AddTextConfigurationFile(source =>
{
source.Path = "app.boduconfig";
source.TargetPath = "src/Web/Startup.cs"; // anchors glob sections like [src/**/*.cs]
source.Optional = false;
source.ReloadOnChange = true;
source.ParseOptions = ConfigurationParseOptions.Strict;
});
// Direct construction - for example, in a custom builder host.
var source = new TextConfigurationSource
{
Path = "app.boduconfig",
ReloadOnChange = true,
TargetPath = "src/Web/Startup.cs",
};
IConfigurationProvider provider = source.Build(builder);
Remarks
Inherits the standard reload-on-change, file-provider, and optional-file behaviors from FileConfigurationSource, matching the conventions used by the JSON, INI, and XML providers shipped by Microsoft. Three Bodu-specific properties extend the base contract: TargetPath drives glob-anchored section matching during resolution, ParseOptions controls how the document is read, and ResolveOptions controls how the resolved view is layered.
Most callers do not construct this type directly; reach for the AddTextConfigurationFile(IConfigurationBuilder, string, string?, bool, bool) extensions instead. Direct construction is appropriate when a host already has the source instance in hand - for example, when wiring a custom IConfigurationBuilder programmatically.
Constructors
TextConfigurationSource()
public TextConfigurationSource()
Properties
ParseOptions
Gets or sets the parse options applied when the file is loaded.
public ConfigurationParseOptions? ParseOptions { get; set; }
Property Value
- ConfigurationParseOptions
The parse options, or null for the defaults.
ResolveOptions
Gets or sets the resolve options applied when projecting the document into the configuration view.
public ConfigurationResolveOptions? ResolveOptions { get; set; }
Property Value
- ConfigurationResolveOptions
The resolve options, or null for the defaults.
TargetPath
Gets or sets the path that each section's glob is matched against during resolution. Defaults to null, in which case no section applies and only the preamble contributes (when ApplyPreambleProperties is set).
public string? TargetPath { get; set; }
Property Value
- string
The target path supplied to the resolver.
Methods
Build(IConfigurationBuilder)
Builds the IConfigurationProvider for this source.
public override IConfigurationProvider Build(IConfigurationBuilder builder)
Parameters
builderIConfigurationBuilder
Returns
- IConfigurationProvider
To be added.
Remarks
The source locates Path as AddJsonFile does: when no
FileProvider is set, a rooted path is served by a
PhysicalFileProvider at the deepest directory on it that
exists (see ResolveFileProvider()), and any other path by the builder's
file provider, which is the provider SetFileProvider sets, the base path SetBasePath sets, or by
default the application's base directory.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |