TomlNode Class
The base class of the mutable TOML document model: TomlTable, TomlArray, TomlTableArray and TomlValue.
public abstract class TomlNodeRemarks
A node has at most one parent. Use TomlNode.DeepClone to add a copy of a node to another container.
Properties
| Name | Description |
|---|---|
| Parent | Gets the table or array that contains the node. |
| Root | Gets the root of the tree that contains the node. |
Parent
TomlNode.csRoot
TomlNode.csIndexers
| Name | Description |
|---|---|
| this[int] | Gets or sets the element at an index of the array. |
| this[string] | Gets or sets the value of a key of the table. The getter returns null when the table has no such key. |
Item overloads
this[int]
TomlNode.csGets or sets the element at an index of the array.
this[string]
TomlNode.csGets or sets the value of a key of the table. The getter returns null when the table has no such key.
Methods
| Name | Description |
|---|---|
| AsArray() | Gets the node as an array. |
| AsTable() | Gets the node as a table. |
| AsTableArray() | Gets the node as an array of tables. |
| AsValue() | Gets the node as a value. |
| Create(TomlElement) | Creates a node from an element of a TomlDocument. |
| DeepClone() | Gets a copy of the node and its descendants, without a parent. |
| DeepEquals(TomlNode?, TomlNode?) | Compares two nodes and their descendants. |
| GetPath() | Gets the path of the node from its root, such as $.servers[0].name. |
| GetValue<T>() | Gets the value of the node converted to T. |
| GetValueKind() | Gets the kind of the value. |
| ToString() | Returns a string that represents the current object. |
| ToTomlString(Utf8TomlWriterOptions) | Gets the TOML text of the node: a document for a table, and a value for the other nodes. |
| WriteTo(Utf8TomlWriter) | Writes the node with a writer: a table as key/value pairs and sub-tables where the writer expects a key, and as an inline table otherwise. |
AsArray()
TomlNode.csGets the node as an array.
public TomlArray AsArray()AsTable()
TomlNode.csGets the node as a table.
public TomlTable AsTable()AsTableArray()
TomlNode.csGets the node as an array of tables.
public TomlTableArray AsTableArray()AsValue()
TomlNode.csGets the node as a value.
public TomlValue AsValue()Create(TomlElement)
TomlNode.csCreates a node from an element of a TomlDocument.
public static TomlNode Create(TomlElement element)DeepClone()
DeepEquals(TomlNode?, TomlNode?)
TomlNode.csCompares two nodes and their descendants.
GetPath()
TomlNode.csGetValue<T>()
TomlNode.csGets the value of the node converted to T.
public T GetValue<T>()Type parameters
T
Returns
T
Exceptions
InvalidOperationException- The node is not a value, or its value cannot be converted.
GetValueKind()
ToString()
TomlNode.csToTomlString(Utf8TomlWriterOptions)
TomlNode.csGets the TOML text of the node: a document for a table, and a value for the other nodes.
public string ToTomlString(Utf8TomlWriterOptions options = default)WriteTo(Utf8TomlWriter)
Writes the node with a writer: a table as key/value pairs and sub-tables where the writer expects a key, and as an inline table otherwise.
public abstract void WriteTo(Utf8TomlWriter writer)Parameters
writerUtf8TomlWriter- The writer.
Operators
op_Explicit overloads
explicit operator TomlDateTime(TomlNode)
TomlNode.csGets the value of a node.
public static explicit operator TomlDateTime(TomlNode value)explicit operator bool(TomlNode)
TomlNode.csexplicit operator DateOnly(TomlNode)
TomlNode.csexplicit operator DateTime(TomlNode)
TomlNode.csexplicit operator DateTimeOffset(TomlNode)
TomlNode.csGets the value of a node.
public static explicit operator DateTimeOffset(TomlNode value)explicit operator decimal(TomlNode)
TomlNode.csexplicit operator double(TomlNode)
TomlNode.csexplicit operator int(TomlNode)
TomlNode.csexplicit operator long(TomlNode)
TomlNode.csexplicit operator float(TomlNode)
TomlNode.csexplicit operator string?(TomlNode?)
TomlNode.csexplicit operator TimeOnly(TomlNode)
TomlNode.csop_Implicit overloads
implicit operator TomlNode(TomlDateTime)
TomlNode.csCreates a value node.
public static implicit operator TomlNode(TomlDateTime value)implicit operator TomlNode(bool)
TomlNode.csimplicit operator TomlNode(DateOnly)
TomlNode.csimplicit operator TomlNode(DateTime)
TomlNode.csimplicit operator TomlNode(DateTimeOffset)
TomlNode.csCreates a value node.
public static implicit operator TomlNode(DateTimeOffset value)