Class TomlArray
Represents a TOML array, which is an ordered collection of values.
public class TomlArray : TomlValue, IList<TomlToken>, ICollection<TomlToken>, IEnumerable<TomlToken>, IEnumerable
- Inheritance
-
TomlArray
- Implements
- Derived
- Inherited Members
Remarks
TomlArray implements IList<T> to provide list-like access to its elements. All elements in a TOML array are stored as TomlToken objects. Arrays can contain primitive values, nested tables, or other arrays.
Constructors
TomlArray()
Initializes a new instance of the TomlArray class with an anonymous name.
public TomlArray()
TomlArray(TomlKey)
Initializes a new instance of the TomlArray class with the specified key.
public TomlArray(TomlKey fullName)
Parameters
fullNameTomlKeyThe fully qualified key name for this array.
TomlArray(TomlKey, TomlTokenType)
Initializes a new instance of the TomlArray.
protected TomlArray(TomlKey fullName, TomlTokenType tomlTokenType)
Parameters
fullNameTomlKeytomlTokenTypeTomlTokenType
Properties
Count
Gets the number of elements in the array.
public int Count { get; }
Property Value
FullName
Gets the fully qualified key name for this array.
public TomlKey FullName { get; }
Property Value
IsReadOnly
Gets a value indicating whether the array is read-only. Always returns false.
public bool IsReadOnly { get; }
Property Value
this[int]
Gets the TomlToken on index.
public override TomlToken this[int index] { get; set; }
Parameters
Property Value
this[string]
Always throws InvalidOperationException because TomlArray does not support access by the key.
public override TomlToken this[string key] { get; set; }
Parameters
keystring
Property Value
Name
Gets the simple name of this array (last part of the fully qualified name).
public string Name { get; }
Property Value
Methods
Add(TomlArray)
Adds a TomlArray to the end of the array.
public void Add(TomlArray tomlArray)
Parameters
tomlArrayTomlArrayThe array to add.
Exceptions
- ArgumentNullException
Thrown when
tomlArrayisnull.
Add(TomlTable)
Adds a TomlTable to the end of the array.
public void Add(TomlTable tomlTable)
Parameters
tomlTableTomlTableThe table to add.
Exceptions
- ArgumentNullException
Thrown when
tomlTableisnull.
Add(TomlToken)
Adds a TomlToken to the end of the array.
public void Add(TomlToken tomlValue)
Parameters
tomlValueTomlTokenThe token to add.
Exceptions
- ArgumentNullException
Thrown when
tomlValueisnull.
Add(bool)
Adds a boolean value to the end of the array.
public void Add(bool value)
Parameters
valueboolThe boolean value.
Add(byte)
Adds an 8-bit unsigned integer value to the end of the array.
public void Add(byte value)
Parameters
valuebyteThe byte value.
Add(DateTime)
Adds a datetime value to the end of the array.
public void Add(DateTime value)
Parameters
valueDateTimeThe datetime value.
Add(decimal)
Adds a decimal value to the end of the array.
public void Add(decimal value)
Parameters
valuedecimalThe decimal value.
Add(double)
Adds a double-precision floating-point value to the end of the array.
public void Add(double value)
Parameters
valuedoubleThe double value.
Add(Guid)
Adds a GUID value to the end of the array (stored as a string).
public void Add(Guid value)
Parameters
valueGuidThe GUID value.
Add(short)
Adds a 16-bit integer value to the end of the array.
public void Add(short value)
Parameters
valueshortThe short integer value.
Add(int)
Adds a 32-bit integer value to the end of the array.
public void Add(int value)
Parameters
valueintThe integer value.
Add(long)
Adds a 64-bit integer value to the end of the array.
public void Add(long value)
Parameters
valuelongThe long integer value.
Add(sbyte)
Adds an 8-bit signed integer value to the end of the array.
public void Add(sbyte value)
Parameters
valuesbyteThe signed byte value.
Add(float)
Adds a single-precision floating-point value to the end of the array.
public void Add(float value)
Parameters
valuefloatThe float value.
Add(string)
Adds a string value to the end of the array.
public void Add(string value)
Parameters
valuestringThe string value.
Clear()
Removes all elements from the array.
public void Clear()
Contains(TomlToken)
Determines whether the array contains a specific element.
public bool Contains(TomlToken item)
Parameters
itemTomlTokenThe element to locate.
Returns
- bool
trueif the element is found; otherwise,false.
CopyTo(TomlToken[], int)
Copies the elements of the array to an array, starting at a specified array index.
public void CopyTo(TomlToken[] array, int arrayIndex)
Parameters
arrayTomlToken[]The destination array.
arrayIndexintThe zero-based index in the destination array where copying begins.
GetChildren()
Enumerates all children of this TomlToken.
protected override IEnumerable<TomlToken> GetChildren()
Returns
IndexOf(TomlToken)
Determines the index of a specific element in the array.
public int IndexOf(TomlToken item)
Parameters
itemTomlTokenThe element to locate.
Returns
- int
The index of the element, or -1 if not found.
Insert(int, TomlToken)
public void Insert(int index, TomlToken item)
Parameters
Remove(TomlToken)
Removes the first occurrence of a specific element from the array.
public bool Remove(TomlToken item)
Parameters
itemTomlTokenThe element to remove.
Returns
- bool
trueif the element was successfully removed; otherwise,false.
RemoveAt(int)
public void RemoveAt(int index)
Parameters
indexint
ToString()
public override string ToString()