Table of Contents

BencodeConfigurationSource Class

Definition

Namespace
Bodu.Extensions.Configuration.Text
Assembly
Bodu.Extensions.Configuration.Text.dll
Package
Bodu.Extensions.Configuration.Text 1.0.0
Source
BencodeConfigurationSource.cs

Represents a Bencode configuration source - either a one-shot Stream or a file path - that produces a read-only BencodeConfigurationProvider.

public sealed class BencodeConfigurationSource : IConfigurationSource
Inheritance
BencodeConfigurationSource
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()
    .AddBencodeFile("appsettings.bencode", optional: true)
    .Build();

// The source itself is the seam for custom composition:
var source = new BencodeConfigurationSource { Path = "appsettings.bencode", Optional = true };

Constructors

BencodeConfigurationSource()

public BencodeConfigurationSource()

Properties

Optional

Gets or sets a value indicating whether a missing file at Path is permitted.

public bool Optional { get; set; }

Property Value

bool

true when the file may be absent; otherwise false.

Path

Gets or sets the path of the Bencode file to read.

public string? Path { get; set; }

Property Value

string

The configured file path, or null when the source is stream-backed.

Stream

Gets or sets the stream containing a Bencode document. Takes precedence over Path when both are set.

public Stream? Stream { get; set; }

Property Value

Stream

The configured stream, or null when the source is file-backed.

Methods

Build(IConfigurationBuilder)

Builds the read-only provider for this source.

public IConfigurationProvider Build(IConfigurationBuilder builder)

Parameters

builder IConfigurationBuilder

The configuration builder.

Returns

IConfigurationProvider

A BencodeConfigurationProvider.

Applies to

ProductVersions
.NET8, 10