DotEnvObject Class
Definition
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
keystringThe key name.
Property Value
- DotEnvValue
The value node associated with
key.
Exceptions
- ArgumentNullException
Thrown when
keyor the assigned value is null.- KeyNotFoundException
Thrown by the getter when
keyis 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
keystringThe key name.
Returns
Exceptions
- ArgumentNullException
Thrown when
keyis 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
keystringThe key name.
Returns
Exceptions
- ArgumentNullException
Thrown when
keyis null.
Remove(string)
Removes the entry with the specified key.
public bool Remove(string key)
Parameters
keystringThe key name.
Returns
Exceptions
- ArgumentNullException
Thrown when
keyis 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
Exceptions
- ArgumentNullException
Thrown when
keyis null.- KeyNotFoundException
Thrown when
keyis 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
keystringThe key name.
valueDotEnvValue
Returns
Exceptions
- ArgumentNullException
Thrown when
keyis null.
WriteTo(ref Utf8DotEnvWriter)
Writes this node's DotEnv representation to the supplied writer.
public override void WriteTo(ref Utf8DotEnvWriter writer)
Parameters
writerUtf8DotEnvWriterThe writer that receives the DotEnv bytes.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |