TomlConfigurationSource Class
Definition
- Namespace
- Bodu.Extensions.Configuration.Text
- Assembly
- Bodu.Extensions.Configuration.Text.dll
- Package
- Bodu.Extensions.Configuration.Text 1.3.0
Represents a TOML configuration source - either a one-shot Stream or a file path - that produces a read-only TomlConfigurationProvider.
public sealed class TomlConfigurationSource : IConfigurationSource
- Inheritance
-
TomlConfigurationSource
- Implements
- Inherited Members
- Extension Methods
Remarks
The source is read once when the configuration is built; it attaches no reload-on-change machinery. Exactly one of Stream or Path should be set.
// Normally added through the extension method:
IConfiguration configuration = new ConfigurationBuilder()
.AddTomlFile("appsettings.toml", optional: true)
.Build();
// The source itself is the seam for custom composition:
var source = new TomlConfigurationSource { Path = "appsettings.toml", Optional = true };
Constructors
TomlConfigurationSource()
public TomlConfigurationSource()
Properties
Optional
Gets or sets a value indicating whether a missing file at Path is permitted.
public bool Optional { get; set; }
Property Value
Path
Gets or sets the path of the TOML file to read, rooted or relative to the configuration builder's file provider.
public string? Path { get; set; }
Property Value
Stream
Gets or sets the stream containing UTF-8 TOML text. Takes precedence over Path when both are set.
public Stream? Stream { get; set; }
Property Value
Methods
Build(IConfigurationBuilder)
Builds the read-only provider for this source.
public IConfigurationProvider Build(IConfigurationBuilder builder)
Parameters
builderIConfigurationBuilderThe configuration builder.
Returns
Remarks
A file-backed source locates Path as AddJsonFile does: a rooted path is read from the file
system, and any other path through the builder's file provider, which is the provider SetFileProvider
sets, the base path SetBasePath sets, or by default the application's base directory.
Exceptions
- ArgumentNullException
Thrown when
builderis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |