Table of Contents

DotEnvElement Struct

Definition

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

Represents a single element - the root object or one of its string values - within a DotEnvDocument, shaped after System.Text.Json's JsonElement.

public readonly struct DotEnvElement
Inherited Members
Extension Methods

Properties

ValueKind

Gets the value kind of this element.

public DotEnvValueKind ValueKind { get; }

Property Value

DotEnvValueKind

Object for the root; otherwise String.

Methods

EnumerateObject()

Enumerates the properties of an object element in source order.

public DotEnvElement.ObjectEnumerator EnumerateObject()

Returns

DotEnvElement.ObjectEnumerator

An enumerator over the object's properties.

Exceptions

InvalidOperationException

Thrown when this element is not an object.

ObjectDisposedException

Thrown when the owning document has been disposed.

GetProperty(string)

Gets the value element for the specified property name.

public DotEnvElement GetProperty(string name)

Parameters

name string

The property name.

Returns

DotEnvElement

The value element.

Exceptions

ArgumentNullException

Thrown when name is null.

InvalidOperationException

Thrown when this element is not an object.

KeyNotFoundException

Thrown when the property is not present.

ObjectDisposedException

Thrown when the owning document has been disposed.

GetString()

Gets the string value of a String element.

public string GetString()

Returns

string

The string value.

Exceptions

InvalidOperationException

Thrown when this element is not a string.

ObjectDisposedException

Thrown when the owning document has been disposed.

TryGetProperty(string, out DotEnvElement)

Attempts to get the value element for the specified property name.

public bool TryGetProperty(string name, out DotEnvElement value)

Parameters

name string

The property name.

value DotEnvElement

When this method returns true, the value element; otherwise the default element.

Returns

bool

true when the property is present; otherwise false.

Exceptions

ArgumentNullException

Thrown when name is null.

InvalidOperationException

Thrown when this element is not an object.

ObjectDisposedException

Thrown when the owning document has been disposed.

Applies to

ProductVersions
.NET8, 10