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
Fields
obj
The one value; null is allowed.
protected readonly object obj
Field Value
Properties
Count
Always 1.
public int Count { get; }
Property Value
IsFixedSize
Always true: the merge expands it instead of appending to it.
public bool IsFixedSize { get; }
Property Value
IsReadOnly
Always true.
public bool IsReadOnly { get; }
Property Value
IsSynchronized
Always true: the list never changes, so reading it from several threads is safe.
public bool IsSynchronized { get; }
Property Value
this[int]
The one value at index 0; setting always throws.
public object this[int index] { get; set; }
Parameters
indexintMust 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
Methods
Add(object)
Always throws: the list is read-only.
public int Add(object value)
Parameters
valueobjectIgnored.
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
valueobjectThe value to look for.
Returns
CopyTo(Array, int)
Writes the value into array at index.
public void CopyTo(Array array, int index)
Parameters
Exceptions
- NullReferenceException
When
arrayis null.- IndexOutOfRangeException
When
indexis outsidearray.- 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
otherExpandableListThe list to compare with.
Returns
Equals(object)
Whether obj is an ExpandableList of the exact same type wrapping an equal value.
public override bool Equals(object obj)
Parameters
objobjectThe 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
Type Parameters
TThe 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
valueobjectThe 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
Exceptions
- NotSupportedException
Always.
Remove(object)
Always throws: the list is read-only.
public void Remove(object value)
Parameters
valueobjectIgnored.
Exceptions
- NotSupportedException
Always.
RemoveAt(int)
Always throws: the list is read-only.
public void RemoveAt(int index)
Parameters
indexintIgnored.
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
leftExpandableListThe first list.
rightExpandableListThe second list.
Returns
operator !=(ExpandableList, ExpandableList)
The negation of operator ==(ExpandableList, ExpandableList).
public static bool operator !=(ExpandableList left, ExpandableList right)
Parameters
leftExpandableListThe first list.
rightExpandableListThe second list.