Bodu.Text.DotEnv.Nodes Namespace
- Package
-
Bodu.Text.DotEnv 1.0.0
Purpose
Bodu.Text.DotEnv.Nodes is the mutable document object model of Bodu.Text.DotEnv: parse a .env file into an editable, insertion-ordered object, add or change entries, toggle each entry's export flag, and write it back through the Utf8DotEnvWriter. It is the tier for programmatic authoring and rewrites; for read-only lookup use the sibling Bodu.Text.DotEnv.Document tier, and for typed settings use the DotEnvSerializer.
Key types
- DotEnvNode - abstract base:
Parse(fromstringor UTF-8 bytes, returning the root object),AsObject/AsValue,ValueKind,DeepClone,WriteTo,ToUtf8Bytes, and an implicit conversion fromstring. - DotEnvObject - the root:
Keys,Count,ContainsKey/TryGetValue/Remove, a string indexer that adds or replaces, and the per-entryIsExport/SetExport. - DotEnvValue - a single entry with a settable
Value.
Example
using Bodu.Text.DotEnv.Nodes;
DotEnvObject env = DotEnvNode.Parse("export APP_ENV=production\nAPP_PORT=8080\n");
env["APP_PORT"].Value = "9090";
env["APP_DEBUG"] = new DotEnvValue("false");
env.SetExport("APP_DEBUG", true);
byte[] back = env.ToUtf8Bytes(); // export flags survive the round trip
Notes
- Export flag preserved. Unlike the other line-format node DOMs, each entry carries its
exportprefix through parse → edit → write. - Comments are not retained. The DOM is otherwise trivia-free; the writer re-quotes values minimally on output.
- See also: the line-formats introduction and the DotEnv guide (Pattern 3 - author and round-trip with the mutable DOM).
Classes
- DotEnvNode
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.
- DotEnvObject
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
exportflag preserved for round-tripping.
- DotEnvValue
Represents a string-valued leaf in a mutable DotEnv document tree.