DotEnvNode Class
Definition
Represents a node in a mutable DotEnv document tree. A DotEnv document is a flat, ordered object of string-valued keys, so the tree has exactly two concrete shapes: a DotEnvObject root and the DotEnvValue string leaves it contains.
public abstract class DotEnvNode
- Inheritance
-
DotEnvNode
- Derived
- Inherited Members
- Extension Methods
Properties
ValueKind
Gets the value kind of this node.
public abstract DotEnvValueKind ValueKind { get; }
Property Value
- DotEnvValueKind
The node's DotEnvValueKind.
Methods
AsObject()
Returns this node as a DotEnvObject.
public DotEnvObject AsObject()
Returns
- DotEnvObject
This node cast to DotEnvObject.
Exceptions
- InvalidOperationException
Thrown when this node is not an object.
AsValue()
Returns this node as a DotEnvValue.
public DotEnvValue AsValue()
Returns
- DotEnvValue
This node cast to DotEnvValue.
Exceptions
- InvalidOperationException
Thrown when this node is not a value.
DeepClone()
Creates a deep copy of this node.
public abstract DotEnvNode DeepClone()
Returns
- DotEnvNode
The cloned node.
Parse(ReadOnlySpan<byte>)
Parses the supplied UTF-8 bytes into a mutable DotEnv object tree.
public static DotEnvObject Parse(ReadOnlySpan<byte> utf8DotEnv)
Parameters
utf8DotEnvReadOnlySpan<byte>The DotEnv source bytes.
Returns
- DotEnvObject
The parsed DotEnvObject root.
Exceptions
- DotEnvFormatException
Thrown when the bytes are not valid DotEnv.
Parse(ReadOnlySpan<byte>, DotEnvReaderOptions)
Parses the supplied UTF-8 bytes into a mutable DotEnv object tree using the supplied reader options.
public static DotEnvObject Parse(ReadOnlySpan<byte> utf8DotEnv, DotEnvReaderOptions options)
Parameters
utf8DotEnvReadOnlySpan<byte>The DotEnv source bytes.
optionsDotEnvReaderOptionsThe reader options.
Returns
- DotEnvObject
The parsed DotEnvObject root.
Exceptions
- DotEnvFormatException
Thrown when the bytes are not valid DotEnv.
Parse(string)
Parses the supplied DotEnv text into a mutable DotEnv object tree.
public static DotEnvObject Parse(string dotEnv)
Parameters
dotEnvstringThe DotEnv source text.
Returns
- DotEnvObject
The parsed DotEnvObject root.
Exceptions
- ArgumentNullException
Thrown when
dotEnvis null.- DotEnvFormatException
Thrown when the text is not valid DotEnv.
ToString()
Serializes this node to DotEnv text.
public override string ToString()
Returns
- string
The DotEnv text.
Exceptions
- ArgumentException
Thrown when the node holds a key that is not a key the reader reads back, one that does not match
[A-Za-z_][A-Za-z0-9_]*.
ToUtf8Bytes()
Serializes this node to a new UTF-8 byte array.
public byte[] ToUtf8Bytes()
Returns
- byte[]
The DotEnv bytes.
Exceptions
- ArgumentException
Thrown when the node holds a key that is not a key the reader reads back, one that does not match
[A-Za-z_][A-Za-z0-9_]*.
WriteTo(ref Utf8DotEnvWriter)
Writes this node's DotEnv representation to the supplied writer.
public abstract void WriteTo(ref Utf8DotEnvWriter writer)
Parameters
writerUtf8DotEnvWriterThe writer that receives the DotEnv bytes.
Exceptions
- ArgumentException
Thrown when the node holds a key that is not a key the reader reads back, one that does not match
[A-Za-z_][A-Za-z0-9_]*.
Operators
implicit operator DotEnvNode(string)
Converts a string to a DotEnvValue.
public static implicit operator DotEnvNode(string value)
Parameters
valuestringThe string value.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |