DotEnvElement Struct
Definition
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
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
namestringThe property name.
Returns
- DotEnvElement
The value element.
Exceptions
- ArgumentNullException
Thrown when
nameis 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
namestringThe property name.
valueDotEnvElementWhen this method returns true, the value element; otherwise the default element.
Returns
Exceptions
- ArgumentNullException
Thrown when
nameis null.- InvalidOperationException
Thrown when this element is not an object.
- ObjectDisposedException
Thrown when the owning document has been disposed.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |