Files
Dec2017-Script-Dump/mscorlib/System/Collections/CollectionBase.cs
T
2026-06-04 11:42:34 +02:00

391 lines
18 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace System.Collections
{
/// <summary>Provides the abstract base class for a strongly typed collection.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x02000125 RID: 293
[ComVisible(true)]
[Serializable]
public abstract class CollectionBase : IEnumerable, ICollection, IList
{
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.CollectionBase" /> class with the default initial capacity.</summary>
// Token: 0x06000F30 RID: 3888 RVA: 0x00040194 File Offset: 0x0003E394
protected CollectionBase()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.CollectionBase" /> class with the specified capacity.</summary>
/// <param name="capacity">The number of elements that the new list can initially store.</param>
// Token: 0x06000F31 RID: 3889 RVA: 0x0004019C File Offset: 0x0003E39C
protected CollectionBase(int capacity)
{
this.list = new ArrayList(capacity);
}
/// <summary>Copies the entire <see cref="T:System.Collections.CollectionBase" /> to a compatible one-dimensional <see cref="T:System.Array" />, starting at the specified index of the target array.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.CollectionBase" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or-The number of elements in the source <see cref="T:System.Collections.CollectionBase" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.</exception>
/// <exception cref="T:System.InvalidCastException">The type of the source <see cref="T:System.Collections.CollectionBase" /> cannot be cast automatically to the type of the destination <paramref name="array" />.</exception>
// Token: 0x06000F32 RID: 3890 RVA: 0x000401B0 File Offset: 0x0003E3B0
void ICollection.CopyTo(Array array, int index)
{
this.InnerList.CopyTo(array, index);
}
/// <summary>Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.CollectionBase" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.CollectionBase" />.</returns>
// Token: 0x1700025A RID: 602
// (get) Token: 0x06000F33 RID: 3891 RVA: 0x000401C0 File Offset: 0x0003E3C0
object ICollection.SyncRoot
{
get
{
return this.InnerList.SyncRoot;
}
}
/// <summary>Gets a value indicating whether access to the <see cref="T:System.Collections.CollectionBase" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="T:System.Collections.CollectionBase" /> is synchronized (thread safe); otherwise, false. The default is false.</returns>
// Token: 0x1700025B RID: 603
// (get) Token: 0x06000F34 RID: 3892 RVA: 0x000401D0 File Offset: 0x0003E3D0
bool ICollection.IsSynchronized
{
get
{
return this.InnerList.IsSynchronized;
}
}
/// <summary>Adds an object to the end of the <see cref="T:System.Collections.CollectionBase" />.</summary>
/// <returns>The <see cref="T:System.Collections.CollectionBase" /> index at which the <paramref name="value" /> has been added.</returns>
/// <param name="value">The <see cref="T:System.Object" /> to be added to the end of the <see cref="T:System.Collections.CollectionBase" />.</param>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.CollectionBase" /> is read-only.-or-The <see cref="T:System.Collections.CollectionBase" /> has a fixed size.</exception>
// Token: 0x06000F35 RID: 3893 RVA: 0x000401E0 File Offset: 0x0003E3E0
int IList.Add(object value)
{
this.OnValidate(value);
int count = this.InnerList.Count;
this.OnInsert(count, value);
this.InnerList.Add(value);
try
{
this.OnInsertComplete(count, value);
}
catch
{
this.InnerList.RemoveAt(count);
throw;
}
return count;
}
/// <summary>Determines whether the <see cref="T:System.Collections.CollectionBase" /> contains a specific element.</summary>
/// <returns>true if the <see cref="T:System.Collections.CollectionBase" /> contains the specified <paramref name="value" />; otherwise, false.</returns>
/// <param name="value">The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.CollectionBase" />.</param>
// Token: 0x06000F36 RID: 3894 RVA: 0x00040254 File Offset: 0x0003E454
bool IList.Contains(object value)
{
return this.InnerList.Contains(value);
}
/// <summary>Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the first occurrence within the entire <see cref="T:System.Collections.CollectionBase" />.</summary>
/// <returns>The zero-based index of the first occurrence of <paramref name="value" /> within the entire <see cref="T:System.Collections.CollectionBase" />, if found; otherwise, -1.</returns>
/// <param name="value">The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.CollectionBase" />.</param>
// Token: 0x06000F37 RID: 3895 RVA: 0x00040264 File Offset: 0x0003E464
int IList.IndexOf(object value)
{
return this.InnerList.IndexOf(value);
}
/// <summary>Inserts an element into the <see cref="T:System.Collections.CollectionBase" /> at the specified index.</summary>
/// <param name="index">The zero-based index at which <paramref name="value" /> should be inserted.</param>
/// <param name="value">The <see cref="T:System.Object" /> to insert.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.-or-<paramref name="index" /> is greater than <see cref="P:System.Collections.CollectionBase.Count" />.</exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.CollectionBase" /> is read-only.-or-The <see cref="T:System.Collections.CollectionBase" /> has a fixed size.</exception>
// Token: 0x06000F38 RID: 3896 RVA: 0x00040274 File Offset: 0x0003E474
void IList.Insert(int index, object value)
{
this.OnValidate(value);
this.OnInsert(index, value);
this.InnerList.Insert(index, value);
try
{
this.OnInsertComplete(index, value);
}
catch
{
this.InnerList.RemoveAt(index);
throw;
}
}
/// <summary>Removes the first occurrence of a specific object from the <see cref="T:System.Collections.CollectionBase" />.</summary>
/// <param name="value">The <see cref="T:System.Object" /> to remove from the <see cref="T:System.Collections.CollectionBase" />.</param>
/// <exception cref="T:System.ArgumentException">The <paramref name="value" /> parameter was not found in the <see cref="T:System.Collections.CollectionBase" /> object.</exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.CollectionBase" /> is read-only.-or-The <see cref="T:System.Collections.CollectionBase" /> has a fixed size.</exception>
// Token: 0x06000F39 RID: 3897 RVA: 0x000402DC File Offset: 0x0003E4DC
void IList.Remove(object value)
{
this.OnValidate(value);
int num = this.InnerList.IndexOf(value);
if (num == -1)
{
throw new ArgumentException("The element cannot be found.", "value");
}
this.OnRemove(num, value);
this.InnerList.Remove(value);
this.OnRemoveComplete(num, value);
}
/// <summary>Gets a value indicating whether the <see cref="T:System.Collections.CollectionBase" /> has a fixed size.</summary>
/// <returns>true if the <see cref="T:System.Collections.CollectionBase" /> has a fixed size; otherwise, false. The default is false.</returns>
// Token: 0x1700025C RID: 604
// (get) Token: 0x06000F3A RID: 3898 RVA: 0x00040330 File Offset: 0x0003E530
bool IList.IsFixedSize
{
get
{
return this.InnerList.IsFixedSize;
}
}
/// <summary>Gets a value indicating whether the <see cref="T:System.Collections.CollectionBase" /> is read-only.</summary>
/// <returns>true if the <see cref="T:System.Collections.CollectionBase" /> is read-only; otherwise, false. The default is false.</returns>
// Token: 0x1700025D RID: 605
// (get) Token: 0x06000F3B RID: 3899 RVA: 0x00040340 File Offset: 0x0003E540
bool IList.IsReadOnly
{
get
{
return this.InnerList.IsReadOnly;
}
}
/// <summary>Gets or sets the element at the specified index.</summary>
/// <returns>The element at the specified index.</returns>
/// <param name="index">The zero-based index of the element to get or set.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.-or-<paramref name="index" /> is equal to or greater than <see cref="P:System.Collections.CollectionBase.Count" />.</exception>
// Token: 0x1700025E RID: 606
object IList.this[int index]
{
get
{
return this.InnerList[index];
}
set
{
if (index < 0 || index >= this.InnerList.Count)
{
throw new ArgumentOutOfRangeException("index");
}
this.OnValidate(value);
object obj = this.InnerList[index];
this.OnSet(index, obj, value);
this.InnerList[index] = value;
try
{
this.OnSetComplete(index, obj, value);
}
catch
{
this.InnerList[index] = obj;
throw;
}
}
}
/// <summary>Gets the number of elements contained in the <see cref="T:System.Collections.CollectionBase" /> instance. This property cannot be overridden.</summary>
/// <returns>The number of elements contained in the <see cref="T:System.Collections.CollectionBase" /> instance.Retrieving the value of this property is an O(1) operation.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x1700025F RID: 607
// (get) Token: 0x06000F3E RID: 3902 RVA: 0x000403FC File Offset: 0x0003E5FC
public int Count
{
get
{
return this.InnerList.Count;
}
}
/// <summary>Returns an enumerator that iterates through the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> for the <see cref="T:System.Collections.CollectionBase" /> instance.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x06000F3F RID: 3903 RVA: 0x0004040C File Offset: 0x0003E60C
public IEnumerator GetEnumerator()
{
return this.InnerList.GetEnumerator();
}
/// <summary>Removes all objects from the <see cref="T:System.Collections.CollectionBase" /> instance. This method cannot be overridden.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x06000F40 RID: 3904 RVA: 0x0004041C File Offset: 0x0003E61C
public void Clear()
{
this.OnClear();
this.InnerList.Clear();
this.OnClearComplete();
}
/// <summary>Removes the element at the specified index of the <see cref="T:System.Collections.CollectionBase" /> instance. This method is not overridable.</summary>
/// <param name="index">The zero-based index of the element to remove.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.-or-<paramref name="index" /> is equal to or greater than <see cref="P:System.Collections.CollectionBase.Count" />.</exception>
/// <filterpriority>2</filterpriority>
// Token: 0x06000F41 RID: 3905 RVA: 0x00040440 File Offset: 0x0003E640
public void RemoveAt(int index)
{
object obj = this.InnerList[index];
this.OnValidate(obj);
this.OnRemove(index, obj);
this.InnerList.RemoveAt(index);
this.OnRemoveComplete(index, obj);
}
/// <summary>Gets or sets the number of elements that the <see cref="T:System.Collections.CollectionBase" /> can contain.</summary>
/// <returns>The number of elements that the <see cref="T:System.Collections.CollectionBase" /> can contain.</returns>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <see cref="P:System.Collections.CollectionBase.Capacity" /> is set to a value that is less than <see cref="P:System.Collections.CollectionBase.Count" />.</exception>
/// <exception cref="T:System.OutOfMemoryException">There is not enough memory available on the system.</exception>
/// <filterpriority>2</filterpriority>
// Token: 0x17000260 RID: 608
// (get) Token: 0x06000F42 RID: 3906 RVA: 0x00040480 File Offset: 0x0003E680
// (set) Token: 0x06000F43 RID: 3907 RVA: 0x000404A4 File Offset: 0x0003E6A4
[ComVisible(false)]
public int Capacity
{
get
{
if (this.list == null)
{
this.list = new ArrayList();
}
return this.list.Capacity;
}
set
{
if (this.list == null)
{
this.list = new ArrayList();
}
this.list.Capacity = value;
}
}
/// <summary>Gets an <see cref="T:System.Collections.ArrayList" /> containing the list of elements in the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <returns>An <see cref="T:System.Collections.ArrayList" /> representing the <see cref="T:System.Collections.CollectionBase" /> instance itself.Retrieving the value of this property is an O(1) operation.</returns>
// Token: 0x17000261 RID: 609
// (get) Token: 0x06000F44 RID: 3908 RVA: 0x000404D4 File Offset: 0x0003E6D4
protected ArrayList InnerList
{
get
{
if (this.list == null)
{
this.list = new ArrayList();
}
return this.list;
}
}
/// <summary>Gets an <see cref="T:System.Collections.IList" /> containing the list of elements in the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <returns>An <see cref="T:System.Collections.IList" /> representing the <see cref="T:System.Collections.CollectionBase" /> instance itself.</returns>
// Token: 0x17000262 RID: 610
// (get) Token: 0x06000F45 RID: 3909 RVA: 0x000404F4 File Offset: 0x0003E6F4
protected IList List
{
get
{
return this;
}
}
/// <summary>Performs additional custom processes when clearing the contents of the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
// Token: 0x06000F46 RID: 3910 RVA: 0x000404F8 File Offset: 0x0003E6F8
protected virtual void OnClear()
{
}
/// <summary>Performs additional custom processes after clearing the contents of the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
// Token: 0x06000F47 RID: 3911 RVA: 0x000404FC File Offset: 0x0003E6FC
protected virtual void OnClearComplete()
{
}
/// <summary>Performs additional custom processes before inserting a new element into the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which to insert <paramref name="value" />.</param>
/// <param name="value">The new value of the element at <paramref name="index" />.</param>
// Token: 0x06000F48 RID: 3912 RVA: 0x00040500 File Offset: 0x0003E700
protected virtual void OnInsert(int index, object value)
{
}
/// <summary>Performs additional custom processes after inserting a new element into the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which to insert <paramref name="value" />.</param>
/// <param name="value">The new value of the element at <paramref name="index" />.</param>
// Token: 0x06000F49 RID: 3913 RVA: 0x00040504 File Offset: 0x0003E704
protected virtual void OnInsertComplete(int index, object value)
{
}
/// <summary>Performs additional custom processes when removing an element from the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which <paramref name="value" /> can be found.</param>
/// <param name="value">The value of the element to remove from <paramref name="index" />.</param>
// Token: 0x06000F4A RID: 3914 RVA: 0x00040508 File Offset: 0x0003E708
protected virtual void OnRemove(int index, object value)
{
}
/// <summary>Performs additional custom processes after removing an element from the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which <paramref name="value" /> can be found.</param>
/// <param name="value">The value of the element to remove from <paramref name="index" />.</param>
// Token: 0x06000F4B RID: 3915 RVA: 0x0004050C File Offset: 0x0003E70C
protected virtual void OnRemoveComplete(int index, object value)
{
}
/// <summary>Performs additional custom processes before setting a value in the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which <paramref name="oldValue" /> can be found.</param>
/// <param name="oldValue">The value to replace with <paramref name="newValue" />.</param>
/// <param name="newValue">The new value of the element at <paramref name="index" />.</param>
// Token: 0x06000F4C RID: 3916 RVA: 0x00040510 File Offset: 0x0003E710
protected virtual void OnSet(int index, object oldValue, object newValue)
{
}
/// <summary>Performs additional custom processes after setting a value in the <see cref="T:System.Collections.CollectionBase" /> instance.</summary>
/// <param name="index">The zero-based index at which <paramref name="oldValue" /> can be found.</param>
/// <param name="oldValue">The value to replace with <paramref name="newValue" />.</param>
/// <param name="newValue">The new value of the element at <paramref name="index" />.</param>
// Token: 0x06000F4D RID: 3917 RVA: 0x00040514 File Offset: 0x0003E714
protected virtual void OnSetComplete(int index, object oldValue, object newValue)
{
}
/// <summary>Performs additional custom processes when validating a value.</summary>
/// <param name="value">The object to validate.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null.</exception>
// Token: 0x06000F4E RID: 3918 RVA: 0x00040518 File Offset: 0x0003E718
protected virtual void OnValidate(object value)
{
if (value == null)
{
throw new ArgumentNullException("CollectionBase.OnValidate: Invalid parameter value passed to method: null");
}
}
// Token: 0x040003B7 RID: 951
private ArrayList list;
}
}