Table of Contents

YamlArray Class

Definition

Namespace
Bodu.Text.Yaml.Nodes
Assembly
Bodu.Text.Yaml.dll
Package
Bodu.Text.Yaml 1.3.0
Source
YamlArray.cs

Represents a mutable YAML sequence node whose elements are YamlNode values.

public sealed class YamlArray : YamlNode, IList<YamlNode?>, ICollection<YamlNode?>, IEnumerable<YamlNode?>, IEnumerable
Inheritance
YamlArray
Implements
Inherited Members
Extension Methods

Remarks

A node may appear at most once in a tree. Adding, inserting, or assigning a node that already belongs to a container, this sequence included, throws an InvalidOperationException; removing or replacing an element, or clearing the sequence, detaches it so that it can be added elsewhere. Adding the sequence to itself or to one of its own descendants throws an InvalidOperationException as well. A null element is not a node and may appear any number of times.

Constructors

YamlArray()

public YamlArray()

Properties

Count

Gets the number of elements in the sequence.

public int Count { get; }

Property Value

int

The element count.

IsReadOnly

Gets a value indicating whether the sequence is read-only.

public bool IsReadOnly { get; }

Property Value

bool

Always false.

this[int]

Gets or sets the element at the specified index.

public override YamlNode? this[int index] { get; set; }

Parameters

index int

The zero-based index.

Property Value

YamlNode

The element node, or null.

Remarks

Assigning over an element detaches the replaced node, so that it can be added elsewhere. Assigning an element over itself leaves the sequence unchanged.

Exceptions

ArgumentOutOfRangeException

index is less than zero, or is greater than or equal to Count.

InvalidOperationException

The assigned node already belongs to a container, and is not the element at index; or the assigned node is this sequence or one of its ancestors.

Methods

Add(YamlNode?)

Adds an element to the end of the sequence.

public void Add(YamlNode? item)

Parameters

item YamlNode

The element to add.

Exceptions

InvalidOperationException

item already belongs to a container, or is this sequence or one of its ancestors.

Clear()

Removes all elements from the sequence, detaching each of them.

public void Clear()

Contains(YamlNode?)

Determines whether the sequence contains the specified element.

public bool Contains(YamlNode? item)

Parameters

item YamlNode

The element to locate.

Returns

bool

true when the element is present.

CopyTo(YamlNode?[], int)

Copies the sequence elements to an array.

public void CopyTo(YamlNode?[] array, int arrayIndex)

Parameters

array YamlNode[]

The destination array.

arrayIndex int

The starting index in the destination.

GetEnumerator()

Returns an enumerator over the elements.

public IEnumerator<YamlNode?> GetEnumerator()

Returns

IEnumerator<YamlNode>

The element enumerator.

IndexOf(YamlNode?)

Returns the index of the specified element.

public int IndexOf(YamlNode? item)

Parameters

item YamlNode

The element to locate.

Returns

int

The zero-based index, or -1 when not found.

Insert(int, YamlNode?)

Inserts an element at the specified index.

public void Insert(int index, YamlNode? item)

Parameters

index int

The zero-based index.

item YamlNode

The element to insert.

Exceptions

ArgumentOutOfRangeException

index is less than zero, or is greater than Count.

InvalidOperationException

item already belongs to a container, or is this sequence or one of its ancestors.

Remove(YamlNode?)

Removes the first occurrence of the specified element, detaching it.

public bool Remove(YamlNode? item)

Parameters

item YamlNode

The element to remove.

Returns

bool

true when an element was removed.

RemoveAt(int)

Removes the element at the specified index, detaching it.

public void RemoveAt(int index)

Parameters

index int

The zero-based index.

Exceptions

ArgumentOutOfRangeException

index is less than zero, or is greater than or equal to Count.

WriteTo(Utf8YamlWriter)

Writes this node to the given writer.

public override void WriteTo(Utf8YamlWriter writer)

Parameters

writer Utf8YamlWriter

The writer to emit into.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IEnumerator? IEnumerable.GetEnumerator()

Returns

IEnumerator

An IEnumerator object that can be used to iterate through the collection.

Applies to

ProductVersions
.NET8, 10