DotEnvDocument Class
Definition
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
utf8DotEnvReadOnlySpan<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
utf8DotEnvReadOnlySpan<byte>The DotEnv source bytes.
optionsDotEnvReaderOptionsThe 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
dotEnvstringThe DotEnv source text.
Returns
- DotEnvDocument
The parsed document.
Exceptions
- ArgumentNullException
Thrown when
dotEnvis null.- DotEnvFormatException
Thrown when the text is not valid DotEnv.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |