Table of Contents

Class ExpandableList

Namespace
Gym.Collections
Assembly
Gym.dll

ExpandableList is used for representing a single value that should be expanded to a expandable List<T>.

[Obsolete("Part of the legacy Dict's merging: use List<T>. Removed in 2.0 with Gym.Legacy.")]
public class ExpandableList : IList, ICollection, IEnumerable, IEquatable<ExpandableList>, IExpandableList
Inheritance
ExpandableList
Implements
Derived
Inherited Members
Extension Methods

Remarks

A read-only, fixed-size IList of exactly one item: every mutating member throws NotSupportedException. Obsolete with the legacy Dict (DR-56) and removed in 2.0: use List<T>. Footgun: IsSynchronized says true while SyncRoot is null, so lock (list.SyncRoot) throws.

Constructors

ExpandableList(object)

Wraps one value.

public ExpandableList(object obj)

Parameters

obj object

The value; null is allowed.

Fields

obj

The one value; null is allowed.

protected readonly object obj

Field Value

object

Properties

Count

Always 1.

public int Count { get; }

Property Value

int

IsFixedSize

Always true: the merge expands it instead of appending to it.

public bool IsFixedSize { get; }

Property Value

bool

IsReadOnly

Always true.

public bool IsReadOnly { get; }

Property Value

bool

IsSynchronized

Always true: the list never changes, so reading it from several threads is safe.

public bool IsSynchronized { get; }

Property Value

bool

this[int]

The one value at index 0; setting always throws.

public object this[int index] { get; set; }

Parameters

index int

Must be 0.

Property Value

object

The value.

Exceptions

ArgumentOutOfRangeException

When reading an index other than 0.

NotSupportedException

When setting: the list is read-only.

SyncRoot

Always null, though IsSynchronized says true: do not lock on it.

public object SyncRoot { get; }

Property Value

object

Methods

Add(object)

Always throws: the list is read-only.

public int Add(object value)

Parameters

value object

Ignored.

Returns

int

Never returns.

Exceptions

NotSupportedException

Always.

Clear()

Always throws: the list is read-only.

public void Clear()

Exceptions

NotSupportedException

Always.

Contains(object)

Whether value equals the one value (Equals(object, object)).

public bool Contains(object value)

Parameters

value object

The value to look for.

Returns

bool

true when it equals the list's value.

CopyTo(Array, int)

Writes the value into array at index.

public void CopyTo(Array array, int index)

Parameters

array Array

The destination.

index int

The position to write.

Exceptions

NullReferenceException

When array is null.

IndexOutOfRangeException

When index is outside array.

InvalidCastException

When the value does not fit the array's element type.

Equals(ExpandableList)

Whether other wraps an equal value.

public bool Equals(ExpandableList other)

Parameters

other ExpandableList

The list to compare with.

Returns

bool

true when both wrap equal values (or are the same instance).

Equals(object)

Whether obj is an ExpandableList of the exact same type wrapping an equal value.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with.

Returns

bool

true when equal; an ExpandableList<T> never equals a plain one.

Expand()

A new growable list holding the value, its element type the value's run-time type (made by reflection), or a List<T> of object for a null value.

public IList Expand()

Returns

IList

The list of one item.

ExpandToArray()

A one-item array of the value's run-time type (an object array for a null value). Arrays are fixed size: the merge cannot append to it.

public IList ExpandToArray()

Returns

IList

The array.

Expand<T>()

A new growable list holding the one value, typed T.

public virtual List<T> Expand<T>()

Returns

List<T>

A new List<T> of one item.

Type Parameters

T

The list's element type.

Exceptions

InvalidCastException

When the value is not a T.

GetEnumerator()

Enumerates the one value.

public IEnumerator GetEnumerator()

Returns

IEnumerator

An enumerator yielding the value once.

GetHashCode()

The value's hash, 0 for null.

public override int GetHashCode()

Returns

int

The hash.

IndexOf(object)

0 when value equals the one value, otherwise -1.

public int IndexOf(object value)

Parameters

value object

The value to look for.

Returns

int

0 or -1.

Insert(int, object)

Always throws: the list is read-only.

public void Insert(int index, object value)

Parameters

index int

Ignored.

value object

Ignored.

Exceptions

NotSupportedException

Always.

Remove(object)

Always throws: the list is read-only.

public void Remove(object value)

Parameters

value object

Ignored.

Exceptions

NotSupportedException

Always.

RemoveAt(int)

Always throws: the list is read-only.

public void RemoveAt(int index)

Parameters

index int

Ignored.

Exceptions

NotSupportedException

Always.

ToString()

The value's text, or null for a null value.

public override string ToString()

Returns

string

The text.

Operators

operator ==(ExpandableList, ExpandableList)

Value equality, as Equals(object, object) over the two lists.

public static bool operator ==(ExpandableList left, ExpandableList right)

Parameters

left ExpandableList

The first list.

right ExpandableList

The second list.

Returns

bool

true when both are null or wrap equal values.

operator !=(ExpandableList, ExpandableList)

public static bool operator !=(ExpandableList left, ExpandableList right)

Parameters

left ExpandableList

The first list.

right ExpandableList

The second list.

Returns

bool

true when they differ.