Table of Contents

DotEnvObject Class

Definition

Namespace
Bodu.Text.DotEnv.Nodes
Assembly
Bodu.Text.DotEnv.dll
Package
Bodu.Text.DotEnv 1.0.0
Source
DotEnvObject.cs

Represents the root of a mutable DotEnv document tree: an insertion-ordered map of key names to DotEnvValue string leaves, with an optional per-entry export flag preserved for round-tripping.

public sealed class DotEnvObject : DotEnvNode
Inheritance
DotEnvObject
Inherited Members
Extension Methods

Constructors

DotEnvObject()

Initializes a new instance of the DotEnvObject class.

public DotEnvObject()

Properties

Count

Gets the number of entries in this object.

public int Count { get; }

Property Value

int

The entry count.

this[string]

Gets or sets the value associated with the specified key, adding the key at the end when it is new and preserving its position when it already exists.

public DotEnvValue this[string key] { get; set; }

Parameters

key string

The key name.

Property Value

DotEnvValue

The value node associated with key.

Exceptions

ArgumentNullException

Thrown when key or the assigned value is null.

KeyNotFoundException

Thrown by the getter when key is not present.

Keys

Gets the key names in insertion order.

public IReadOnlyList<string> Keys { get; }

Property Value

IReadOnlyList<string>

The ordered key names.

ValueKind

Gets the value kind of this node.

public override DotEnvValueKind ValueKind { get; }

Property Value

DotEnvValueKind

The node's DotEnvValueKind.

Methods

ContainsKey(string)

Determines whether this object contains the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key name.

Returns

bool

true when the key is present; otherwise false.

Exceptions

ArgumentNullException

Thrown when key is null.

DeepClone()

Creates a deep copy of this node.

public override DotEnvNode DeepClone()

Returns

DotEnvNode

The cloned node.

IsExport(string)

Gets a value indicating whether the entry with the specified key is declared with an export prefix.

public bool IsExport(string key)

Parameters

key string

The key name.

Returns

bool

true when the entry carries an export prefix; otherwise false.

Exceptions

ArgumentNullException

Thrown when key is null.

Remove(string)

Removes the entry with the specified key.

public bool Remove(string key)

Parameters

key string

The key name.

Returns

bool

true when an entry was removed; otherwise false.

Exceptions

ArgumentNullException

Thrown when key is null.

SetExport(string, bool)

Sets whether the entry with the specified key is declared with an export prefix.

public void SetExport(string key, bool export)

Parameters

key string

The key name.

export bool

true to mark the entry for export; otherwise false.

Exceptions

ArgumentNullException

Thrown when key is null.

KeyNotFoundException

Thrown when key is not present.

TryGetValue(string, out DotEnvValue?)

Attempts to get the value associated with the specified key.

public bool TryGetValue(string key, out DotEnvValue? value)

Parameters

key string

The key name.

value DotEnvValue

When this method returns true, the value; otherwise null.

Returns

bool

true when the key is present; otherwise false.

Exceptions

ArgumentNullException

Thrown when key is null.

WriteTo(ref Utf8DotEnvWriter)

Writes this node's DotEnv representation to the supplied writer.

public override void WriteTo(ref Utf8DotEnvWriter writer)

Parameters

writer Utf8DotEnvWriter

The writer that receives the DotEnv bytes.

Applies to

ProductVersions
.NET8, 10