Class TomlTable
Represents a TOML table (section), which is a collection of key-value pairs and nested tables.
public class TomlTable : TomlValue, IEnumerable<TomlToken>, IDictionary<TomlKey, TomlToken>, ICollection<KeyValuePair<TomlKey, TomlToken>>, IEnumerable<KeyValuePair<TomlKey, TomlToken>>, IEnumerable
- Inheritance
-
TomlTable
- Implements
- Derived
- Inherited Members
Remarks
TomlTable implements IDictionary<TKey, TValue> to provide dictionary-like access to its contents. Keys are represented as TomlKey objects and values are TomlToken instances. Nested tables can be accessed using the indexer with either string keys or TomlKey objects.
Constructors
TomlTable()
Initializes a TOML root table.
public TomlTable()
TomlTable(TomlKey)
Initializes a new instance of the TomlTable class with the specified key.
public TomlTable(TomlKey fullName)
Parameters
fullNameTomlKeyThe fully qualified key name for this table.
TomlTable(TomlKey, TomlTokenType)
Initializes a new instance of the TomlTable
protected TomlTable(TomlKey fulName, TomlTokenType tomlTokenType = TomlTokenType.Table)
Parameters
fulNameTomlKeytomlTokenTypeTomlTokenType
TomlTable(string)
Initializes a new instance of the TomlTable class with the specified name string.
public TomlTable(string name)
Parameters
Properties
Count
public int Count { get; }
Property Value
FullName
Gets the fully qualified key name for this table.
public TomlKey FullName { get; }
Property Value
HasFromInlineTableDefinition
Gets or sets a value indicating whether this table is an inline table defined using brace notation.
public bool HasFromInlineTableDefinition { get; set; }
Property Value
HasFromKeyDefinition
Gets or sets a value indicating whether this table is defined via a key in another table.
public bool HasFromKeyDefinition { get; set; }
Property Value
HasTopLevelDefinition
Gets or sets a value indicating whether this table has a top-level definition in the TOML document.
public bool HasTopLevelDefinition { get; set; }
Property Value
IsArrayOfTablesMember
Gets or sets a value indicating whether this table is a member of an array of tables.
public bool IsArrayOfTablesMember { get; set; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
this[TomlKey]
Gets or sets the value associated with the specified key using a TomlKey.
public override TomlToken this[TomlKey key] { get; set; }
Parameters
Property Value
- TomlToken
The value associated with the key.
Exceptions
- KeyNotFoundException
Thrown if the key is not found when getting.
this[int]
Gets or sets the value at the specified index.
public override TomlToken this[int index] { get; set; }
Parameters
indexintThe zero-based index of the element.
Property Value
- TomlToken
The value at the specified index.
this[string]
Gets or sets the value associated with the specified key using a string key.
public override TomlToken this[string key] { get; set; }
Parameters
keystringThe key as a string.
Property Value
- TomlToken
The value associated with the key.
Exceptions
- KeyNotFoundException
Thrown if the key is not found when getting.
Keys
Gets the collection of keys in the table.
public ICollection<TomlKey> Keys { get; }
Property Value
Name
Gets the simple name of this table (last part of the fully qualified name).
public string Name { get; }
Property Value
Values
Gets the collection of values in the table.
public ICollection<TomlToken> Values { get; }
Property Value
Methods
Add(TomlArray)
Adds a nested array to this table.
public void Add(TomlArray tomlArray)
Parameters
tomlArrayTomlArrayThe array to add.
Add(TomlKey, TomlToken)
Adds a key-value pair to the table.
public void Add(TomlKey key, TomlToken value)
Parameters
Add(TomlKey, bool)
Adds a boolean value to the table using a TomlKey.
public void Add(TomlKey key, bool value)
Parameters
Add(TomlKey, byte)
Adds an 8-bit unsigned integer value to the table using a TomlKey.
public void Add(TomlKey key, byte value)
Parameters
Add(TomlKey, DateTime)
Adds a datetime value to the table using a TomlKey.
public void Add(TomlKey key, DateTime value)
Parameters
Add(TomlKey, decimal)
Adds a decimal value to the table using a TomlKey.
public void Add(TomlKey key, decimal value)
Parameters
Add(TomlKey, double)
Adds a double-precision floating-point value to the table using a TomlKey.
public void Add(TomlKey key, double value)
Parameters
Add(TomlKey, Guid)
Adds a GUID value to the table using a TomlKey (stored as a string).
public void Add(TomlKey key, Guid value)
Parameters
Add(TomlKey, short)
Adds a 16-bit integer value to the table using a TomlKey.
public void Add(TomlKey key, short value)
Parameters
Add(TomlKey, int)
Adds a 32-bit integer value to the table using a TomlKey.
public void Add(TomlKey key, int value)
Parameters
Add(TomlKey, long)
Adds a 64-bit integer value to the table using a TomlKey.
public void Add(TomlKey key, long value)
Parameters
Add(TomlKey, sbyte)
Adds an 8-bit signed integer value to the table using a TomlKey.
public void Add(TomlKey key, sbyte value)
Parameters
Add(TomlKey, float)
Adds a single-precision floating-point value to the table using a TomlKey.
public void Add(TomlKey key, float value)
Parameters
Add(TomlKey, string)
Adds a string value to the table using a TomlKey.
public void Add(TomlKey key, string value)
Parameters
Add(TomlTable)
Adds a nested table to this table.
public void Add(TomlTable tomlTable)
Parameters
tomlTableTomlTableThe table to add.
Add(KeyValuePair<TomlKey, TomlToken>)
public void Add(KeyValuePair<TomlKey, TomlToken> item)
Parameters
itemKeyValuePair<TomlKey, TomlToken>
Add(string, TomlToken)
Adds a key-value pair to the table using a string key.
public void Add(string key, TomlToken value)
Parameters
keystringThe key as a string. A TomlKey will be created from this string.
valueTomlTokenThe value as a TomlToken.
Add(string, bool)
Adds a boolean value to the table.
public void Add(string key, bool value)
Parameters
Add(string, byte)
Adds an 8-bit unsigned integer value to the table.
public void Add(string key, byte value)
Parameters
Add(string, DateTime)
Adds a datetime value to the table.
public void Add(string key, DateTime value)
Parameters
Add(string, decimal)
Adds a decimal value to the table.
public void Add(string key, decimal value)
Parameters
Add(string, double)
Adds a double-precision floating-point value to the table.
public void Add(string key, double value)
Parameters
Add(string, Guid)
Adds a GUID value to the table (stored as a string).
public void Add(string key, Guid value)
Parameters
Add(string, short)
Adds a 16-bit integer value to the table.
public void Add(string key, short value)
Parameters
Add(string, int)
Adds a 32-bit integer value to the table.
public void Add(string key, int value)
Parameters
Add(string, long)
Adds a 64-bit integer value to the table.
public void Add(string key, long value)
Parameters
Add(string, sbyte)
Adds an 8-bit signed integer value to the table.
public void Add(string key, sbyte value)
Parameters
Add(string, float)
Adds a single-precision floating-point value to the table.
public void Add(string key, float value)
Parameters
Add(string, string)
Adds a string value to the table.
public void Add(string key, string value)
Parameters
Clear()
public void Clear()
Contains(KeyValuePair<TomlKey, TomlToken>)
public bool Contains(KeyValuePair<TomlKey, TomlToken> item)
Parameters
itemKeyValuePair<TomlKey, TomlToken>
Returns
ContainsKey(TomlKey)
Determines whether the table contains a key.
public bool ContainsKey(TomlKey key)
Parameters
Returns
- bool
trueif the table contains the specified key; otherwise,false.
ContainsKey(string)
Determines whether the table contains a key.
public bool ContainsKey(string key)
Parameters
keystringThe key as a string.
Returns
- bool
trueif the table contains the specified key; otherwise,false.
CopyTo(KeyValuePair<TomlKey, TomlToken>[], int)
public void CopyTo(KeyValuePair<TomlKey, TomlToken>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<TomlKey, TomlToken>[]arrayIndexint
GetChildren()
Enumerates all children of this TomlToken.
protected override IEnumerable<TomlToken> GetChildren()
Returns
GetEnumerator()
public IEnumerator<KeyValuePair<TomlKey, TomlToken>> GetEnumerator()
Returns
PropagateTagsToInnerTable(TomlTable)
Propagates HasFromKeyDefinition, HasTopLevelDefinition and HasFromInlineTableDefinition
tags to tomlTable.
protected virtual void PropagateTagsToInnerTable(TomlTable tomlTable)
Parameters
tomlTableTomlTable
PropagateTagsToUnresolvedTables()
Propagates HasFromKeyDefinition, HasTopLevelDefinition and HasFromInlineTableDefinition tags to all currently 'unresolved' tables.
protected virtual void PropagateTagsToUnresolvedTables()
Remove(TomlKey)
Removes a key-value pair from the table.
public bool Remove(TomlKey key)
Parameters
Returns
- bool
trueif the key was found and removed; otherwise,false.
Remove(KeyValuePair<TomlKey, TomlToken>)
public bool Remove(KeyValuePair<TomlKey, TomlToken> item)
Parameters
itemKeyValuePair<TomlKey, TomlToken>
Returns
Remove(string)
Removes a key-value pair from the table.
public bool Remove(string key)
Parameters
keystringThe key as a string.
Returns
- bool
trueif the key was found and removed; otherwise,false.
ToString()
public override string ToString()
Returns
TryGetValue(TomlKey, out TomlToken)
Attempts to get the value associated with the specified key.
public bool TryGetValue(TomlKey key, out TomlToken value)
Parameters
keyTomlKeyThe key as a TomlKey object.
valueTomlTokenThe value associated with the key, if found; otherwise,
null.
Returns
- bool
trueif the key is found; otherwise,false.