Table of Contents

Class TomlTable

Namespace
RStein.TOML
Assembly
RStein.TOML.dll

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

fullName TomlKey

The 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

fulName TomlKey
tomlTokenType TomlTokenType

TomlTable(string)

Initializes a new instance of the TomlTable class with the specified name string.

public TomlTable(string name)

Parameters

name string

The name of the table. A TomlKey will be created from this string.

Properties

Count

public int Count { get; }

Property Value

int

FullName

Gets the fully qualified key name for this table.

public TomlKey FullName { get; }

Property Value

TomlKey

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

bool

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

bool

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

bool

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

bool

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

this[TomlKey]

Gets or sets the value associated with the specified key using a TomlKey.

public override TomlToken this[TomlKey key] { get; set; }

Parameters

key TomlKey

The key as a TomlKey object.

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

index int

The 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

key string

The 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

ICollection<TomlKey>

Name

Gets the simple name of this table (last part of the fully qualified name).

public string Name { get; }

Property Value

string

Values

Gets the collection of values in the table.

public ICollection<TomlToken> Values { get; }

Property Value

ICollection<TomlToken>

Methods

Add(TomlArray)

Adds a nested array to this table.

public void Add(TomlArray tomlArray)

Parameters

tomlArray TomlArray

The array to add.

Add(TomlKey, TomlToken)

Adds a key-value pair to the table.

public void Add(TomlKey key, TomlToken value)

Parameters

key TomlKey

The key as a TomlKey object.

value TomlToken

The value as a TomlToken.

Add(TomlKey, bool)

Adds a boolean value to the table using a TomlKey.

public void Add(TomlKey key, bool value)

Parameters

key TomlKey

The key as a TomlKey object.

value bool

The boolean value.

Add(TomlKey, byte)

Adds an 8-bit unsigned integer value to the table using a TomlKey.

public void Add(TomlKey key, byte value)

Parameters

key TomlKey

The key as a TomlKey object.

value byte

The byte value.

Add(TomlKey, DateTime)

Adds a datetime value to the table using a TomlKey.

public void Add(TomlKey key, DateTime value)

Parameters

key TomlKey

The key as a TomlKey object.

value DateTime

The datetime value.

Add(TomlKey, decimal)

Adds a decimal value to the table using a TomlKey.

public void Add(TomlKey key, decimal value)

Parameters

key TomlKey

The key as a TomlKey object.

value decimal

The decimal value.

Add(TomlKey, double)

Adds a double-precision floating-point value to the table using a TomlKey.

public void Add(TomlKey key, double value)

Parameters

key TomlKey

The key as a TomlKey object.

value double

The double value.

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

key TomlKey

The key as a TomlKey object.

value Guid

The GUID value.

Add(TomlKey, short)

Adds a 16-bit integer value to the table using a TomlKey.

public void Add(TomlKey key, short value)

Parameters

key TomlKey

The key as a TomlKey object.

value short

The short integer value.

Add(TomlKey, int)

Adds a 32-bit integer value to the table using a TomlKey.

public void Add(TomlKey key, int value)

Parameters

key TomlKey

The key as a TomlKey object.

value int

The integer value.

Add(TomlKey, long)

Adds a 64-bit integer value to the table using a TomlKey.

public void Add(TomlKey key, long value)

Parameters

key TomlKey

The key as a TomlKey object.

value long

The long integer value.

Add(TomlKey, sbyte)

Adds an 8-bit signed integer value to the table using a TomlKey.

public void Add(TomlKey key, sbyte value)

Parameters

key TomlKey

The key as a TomlKey object.

value sbyte

The signed byte value.

Add(TomlKey, float)

Adds a single-precision floating-point value to the table using a TomlKey.

public void Add(TomlKey key, float value)

Parameters

key TomlKey

The key as a TomlKey object.

value float

The float value.

Add(TomlKey, string)

Adds a string value to the table using a TomlKey.

public void Add(TomlKey key, string value)

Parameters

key TomlKey

The key as a TomlKey object.

value string

The string value.

Add(TomlTable)

Adds a nested table to this table.

public void Add(TomlTable tomlTable)

Parameters

tomlTable TomlTable

The table to add.

Add(KeyValuePair<TomlKey, TomlToken>)

public void Add(KeyValuePair<TomlKey, TomlToken> item)

Parameters

item KeyValuePair<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

key string

The key as a string. A TomlKey will be created from this string.

value TomlToken

The value as a TomlToken.

Add(string, bool)

Adds a boolean value to the table.

public void Add(string key, bool value)

Parameters

key string

The key as a string.

value bool

The boolean value.

Add(string, byte)

Adds an 8-bit unsigned integer value to the table.

public void Add(string key, byte value)

Parameters

key string

The key as a string.

value byte

The byte value.

Add(string, DateTime)

Adds a datetime value to the table.

public void Add(string key, DateTime value)

Parameters

key string

The key as a string.

value DateTime

The datetime value.

Add(string, decimal)

Adds a decimal value to the table.

public void Add(string key, decimal value)

Parameters

key string

The key as a string.

value decimal

The decimal value.

Add(string, double)

Adds a double-precision floating-point value to the table.

public void Add(string key, double value)

Parameters

key string

The key as a string.

value double

The double value.

Add(string, Guid)

Adds a GUID value to the table (stored as a string).

public void Add(string key, Guid value)

Parameters

key string

The key as a string.

value Guid

The GUID value.

Add(string, short)

Adds a 16-bit integer value to the table.

public void Add(string key, short value)

Parameters

key string

The key as a string.

value short

The short integer value.

Add(string, int)

Adds a 32-bit integer value to the table.

public void Add(string key, int value)

Parameters

key string

The key as a string.

value int

The integer value.

Add(string, long)

Adds a 64-bit integer value to the table.

public void Add(string key, long value)

Parameters

key string

The key as a string.

value long

The long integer value.

Add(string, sbyte)

Adds an 8-bit signed integer value to the table.

public void Add(string key, sbyte value)

Parameters

key string

The key as a string.

value sbyte

The signed byte value.

Add(string, float)

Adds a single-precision floating-point value to the table.

public void Add(string key, float value)

Parameters

key string

The key as a string.

value float

The float value.

Add(string, string)

Adds a string value to the table.

public void Add(string key, string value)

Parameters

key string

The key as a string.

value string

The string value.

Clear()

public void Clear()

Contains(KeyValuePair<TomlKey, TomlToken>)

public bool Contains(KeyValuePair<TomlKey, TomlToken> item)

Parameters

item KeyValuePair<TomlKey, TomlToken>

Returns

bool

ContainsKey(TomlKey)

Determines whether the table contains a key.

public bool ContainsKey(TomlKey key)

Parameters

key TomlKey

The key as a TomlKey object.

Returns

bool

true if the table contains the specified key; otherwise, false.

ContainsKey(string)

Determines whether the table contains a key.

public bool ContainsKey(string key)

Parameters

key string

The key as a string.

Returns

bool

true if the table contains the specified key; otherwise, false.

CopyTo(KeyValuePair<TomlKey, TomlToken>[], int)

public void CopyTo(KeyValuePair<TomlKey, TomlToken>[] array, int arrayIndex)

Parameters

array KeyValuePair<TomlKey, TomlToken>[]
arrayIndex int

GetChildren()

Enumerates all children of this TomlToken.

protected override IEnumerable<TomlToken> GetChildren()

Returns

IEnumerable<TomlToken>

GetEnumerator()

public IEnumerator<KeyValuePair<TomlKey, TomlToken>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<TomlKey, TomlToken>>

PropagateTagsToInnerTable(TomlTable)

protected virtual void PropagateTagsToInnerTable(TomlTable tomlTable)

Parameters

tomlTable TomlTable

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

key TomlKey

The key as a TomlKey object.

Returns

bool

true if the key was found and removed; otherwise, false.

Remove(KeyValuePair<TomlKey, TomlToken>)

public bool Remove(KeyValuePair<TomlKey, TomlToken> item)

Parameters

item KeyValuePair<TomlKey, TomlToken>

Returns

bool

Remove(string)

Removes a key-value pair from the table.

public bool Remove(string key)

Parameters

key string

The key as a string.

Returns

bool

true if the key was found and removed; otherwise, false.

ToString()

public override string ToString()

Returns

string

TryGetValue(TomlKey, out TomlToken)

Attempts to get the value associated with the specified key.

public bool TryGetValue(TomlKey key, out TomlToken value)

Parameters

key TomlKey

The key as a TomlKey object.

value TomlToken

The value associated with the key, if found; otherwise, null.

Returns

bool

true if the key is found; otherwise, false.