Table of Contents

DotEnvDocument Class

Definition

Namespace
Bodu.Text.DotEnv.Document
Assembly
Bodu.Text.DotEnv.dll
Package
Bodu.Text.DotEnv 1.0.0
Source
DotEnvDocument.cs

Provides a read-only, forward-parsed view over a DotEnv document, shaped after System.Text.Json's JsonDocument. The document is a flat object of string-valued keys; comment trivia is not retained.

public sealed class DotEnvDocument : IDisposable
Inheritance
DotEnvDocument
Implements
Inherited Members
Extension Methods

Remarks

The document owns a flat store of decoded entries and must be disposed when no longer needed; every DotEnvElement obtained from it becomes invalid once the document is disposed.

Properties

RootElement

Gets the root element, which is always an object.

public DotEnvElement RootElement { get; }

Property Value

DotEnvElement

The root DotEnvElement.

Exceptions

ObjectDisposedException

Thrown when the document has been disposed.

Methods

Dispose()

Releases the document's backing store. Elements obtained from this document must not be used afterward.

public void Dispose()

Parse(ReadOnlySpan<byte>)

Parses the supplied UTF-8 bytes into a read-only DotEnv document.

public static DotEnvDocument Parse(ReadOnlySpan<byte> utf8DotEnv)

Parameters

utf8DotEnv ReadOnlySpan<byte>

The DotEnv source bytes.

Returns

DotEnvDocument

The parsed document.

Exceptions

DotEnvFormatException

Thrown when the bytes are not valid DotEnv.

Parse(ReadOnlySpan<byte>, DotEnvReaderOptions)

Parses the supplied UTF-8 bytes into a read-only DotEnv document using the supplied reader options.

public static DotEnvDocument Parse(ReadOnlySpan<byte> utf8DotEnv, DotEnvReaderOptions options)

Parameters

utf8DotEnv ReadOnlySpan<byte>

The DotEnv source bytes.

options DotEnvReaderOptions

The reader options.

Returns

DotEnvDocument

The parsed document.

Exceptions

DotEnvFormatException

Thrown when the bytes are not valid DotEnv.

Parse(string)

Parses the supplied DotEnv text into a read-only DotEnv document.

public static DotEnvDocument Parse(string dotEnv)

Parameters

dotEnv string

The DotEnv source text.

Returns

DotEnvDocument

The parsed document.

Exceptions

ArgumentNullException

Thrown when dotEnv is null.

DotEnvFormatException

Thrown when the text is not valid DotEnv.

Applies to

ProductVersions
.NET8, 10