12 [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))]
13 [DebuggerDisplay(
"Count = {Count}")]
14 [__DynamicallyInvokable]
20 private object _syncRoot;
24 [__DynamicallyInvokable]
27 [__DynamicallyInvokable]
36 [__DynamicallyInvokable]
39 [__DynamicallyInvokable]
52 [__DynamicallyInvokable]
53 public T this[
int index]
55 [__DynamicallyInvokable]
60 [__DynamicallyInvokable]
65 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
67 if (index < 0 || index >= items.Count)
69 ThrowHelper.ThrowArgumentOutOfRangeException();
78 [__DynamicallyInvokable]
81 [__DynamicallyInvokable]
84 return items.IsReadOnly;
91 [__DynamicallyInvokable]
94 [__DynamicallyInvokable]
103 [__DynamicallyInvokable]
106 [__DynamicallyInvokable]
109 if (_syncRoot ==
null)
112 if (collection !=
null)
114 _syncRoot = collection.SyncRoot;
131 [__DynamicallyInvokable]
132 object IList.this[
int index]
134 [__DynamicallyInvokable]
139 [__DynamicallyInvokable]
142 ThrowHelper.IfNullAndNullsAreIllegalThenThrow<
T>(value, ExceptionArgument.value);
145 this[index] = (
T)value;
147 catch (InvalidCastException)
149 ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T));
157 [__DynamicallyInvokable]
160 [__DynamicallyInvokable]
163 return items.IsReadOnly;
170 [__DynamicallyInvokable]
171 bool IList.IsFixedSize
173 [__DynamicallyInvokable]
181 [__DynamicallyInvokable]
191 [__DynamicallyInvokable]
196 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list);
203 [__DynamicallyInvokable]
206 if (items.IsReadOnly)
208 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
210 int count = items.Count;
215 [__DynamicallyInvokable]
218 if (items.IsReadOnly)
220 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
233 [__DynamicallyInvokable]
236 items.CopyTo(array, index);
243 [__DynamicallyInvokable]
246 return items.Contains(item);
251 [__DynamicallyInvokable]
254 return items.GetEnumerator();
260 [__DynamicallyInvokable]
263 return items.IndexOf(item);
272 [__DynamicallyInvokable]
275 if (items.IsReadOnly)
277 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
279 if (index < 0 || index > items.Count)
281 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
290 [__DynamicallyInvokable]
293 if (items.IsReadOnly)
295 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
297 int num = items.IndexOf(item);
311 [__DynamicallyInvokable]
314 if (items.IsReadOnly)
316 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
318 if (index < 0 || index >= items.Count)
320 ThrowHelper.ThrowArgumentOutOfRangeException();
326 [__DynamicallyInvokable]
338 [__DynamicallyInvokable]
341 items.Insert(index, item);
349 [__DynamicallyInvokable]
352 items.RemoveAt(index);
361 [__DynamicallyInvokable]
362 protected virtual void SetItem(
int index, T item)
369 [__DynamicallyInvokable]
385 [__DynamicallyInvokable]
390 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
394 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
396 if (array.GetLowerBound(0) != 0)
398 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound);
402 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
404 if (array.Length - index <
Count)
406 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
408 T[] array2 = array as
T[];
411 items.CopyTo(array2, index);
414 Type elementType = array.GetType().GetElementType();
415 Type typeFromHandle = typeof(T);
416 if (!elementType.IsAssignableFrom(typeFromHandle) && !typeFromHandle.IsAssignableFrom(elementType))
418 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidArrayType);
420 object[] array3 = array as
object[];
423 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidArrayType);
425 int count = items.Count;
428 for (
int i = 0; i < count; i++)
430 array3[index++] = items[i];
433 catch (ArrayTypeMismatchException)
435 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidArrayType);
444 [__DynamicallyInvokable]
447 if (items.IsReadOnly)
449 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
451 ThrowHelper.IfNullAndNullsAreIllegalThenThrow<
T>(value, ExceptionArgument.value);
456 catch (InvalidCastException)
458 ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T));
469 [__DynamicallyInvokable]
472 if (IsCompatibleObject(value))
484 [__DynamicallyInvokable]
487 if (IsCompatibleObject(value))
501 [__DynamicallyInvokable]
504 if (items.IsReadOnly)
506 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
508 ThrowHelper.IfNullAndNullsAreIllegalThenThrow<
T>(value, ExceptionArgument.value);
513 catch (InvalidCastException)
515 ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T));
523 [__DynamicallyInvokable]
526 if (items.IsReadOnly)
528 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
530 if (IsCompatibleObject(value))
536 private static bool IsCompatibleObject(
object value)
542 return default(T) ==
null;
void Clear()
Removes all elements from the T:System.Collections.ObjectModel.Collection`1.
bool Remove(T item)
Removes the first occurrence of a specific object from the T:System.Collections.ObjectModel....
virtual void ClearItems()
Removes all elements from the T:System.Collections.ObjectModel.Collection`1.
int IndexOf(T item)
Searches for the specified object and returns the zero-based index of the first occurrence within the...
virtual void InsertItem(int index, T item)
Inserts an element into the T:System.Collections.ObjectModel.Collection`1 at the specified index.
Represents a non-generic collection of objects that can be individually accessed by index.
bool Remove(T item)
Removes the first occurrence of a specific object from the T:System.Collections.Generic....
IList< T > Items
Gets a T:System.Collections.Generic.IList`1 wrapper around the T:System.Collections....
Represents a strongly-typed, read-only collection of elements.
void Insert(int index, T item)
Inserts an element into the T:System.Collections.ObjectModel.Collection`1 at the specified index.
Represents a read-only collection of elements that can be accessed by index.
void Insert(int index, T item)
Inserts an item to the T:System.Collections.Generic.IList`1 at the specified index.
Defines methods to manipulate generic collections.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
virtual void SetItem(int index, T item)
Replaces the element at the specified index.
bool Contains(T item)
Determines whether the T:System.Collections.Generic.ICollection`1 contains a specific value.
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
bool IsReadOnly
Gets a value indicating whether the T:System.Collections.Generic.ICollection`1 is read-only.
Collection()
Initializes a new instance of the T:System.Collections.ObjectModel.Collection`1 class that is empty.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
int Count
Gets the number of elements actually contained in the T:System.Collections.ObjectModel....
void Add(T item)
Adds an object to the end of the T:System.Collections.ObjectModel.Collection`1.
Collection(IList< T > list)
Initializes a new instance of the T:System.Collections.ObjectModel.Collection`1 class as a wrapper fo...
int IndexOf(T item)
Determines the index of a specific item in the T:System.Collections.Generic.IList`1.
void RemoveAt(int index)
Removes the element at the specified index of the T:System.Collections.ObjectModel....
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
virtual void RemoveItem(int index)
Removes the element at the specified index of the T:System.Collections.ObjectModel....
void CopyTo(T[] array, int index)
Copies the entire T:System.Collections.ObjectModel.Collection`1 to a compatible one-dimensional T:Sys...
Represents a collection of objects that can be individually accessed by index.
IEnumerator< T > GetEnumerator()
Returns an enumerator that iterates through the T:System.Collections.ObjectModel.Collection`1.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Provides the base class for a generic collection.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Provides atomic operations for variables that are shared by multiple threads.
Supports a simple iteration over a non-generic collection.
bool Contains(T item)
Determines whether an element is in the T:System.Collections.ObjectModel.Collection`1.
void Add(T item)
Adds an item to the T:System.Collections.Generic.ICollection`1.