using System;
using System.Runtime.Serialization;
namespace System.Collections.Specialized
{
/// Represents a collection of key/value pairs that are accessible by the key or index.
// Token: 0x02000034 RID: 52
[Serializable]
public class OrderedDictionary : ICollection, IOrderedDictionary, IDictionary, IDeserializationCallback, IEnumerable, ISerializable
{
/// Initializes a new instance of the class.
// Token: 0x06000226 RID: 550 RVA: 0x00008664 File Offset: 0x00006864
public OrderedDictionary()
{
this.list = new ArrayList();
this.hash = new Hashtable();
}
/// Initializes a new instance of the class using the specified initial capacity.
/// The initial number of elements that the collection can contain.
// Token: 0x06000227 RID: 551 RVA: 0x00008684 File Offset: 0x00006884
public OrderedDictionary(int capacity)
{
this.initialCapacity = ((capacity >= 0) ? capacity : 0);
this.list = new ArrayList(this.initialCapacity);
this.hash = new Hashtable(this.initialCapacity);
}
/// Initializes a new instance of the class using the specified comparer.
/// The to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of .
// Token: 0x06000228 RID: 552 RVA: 0x000086D0 File Offset: 0x000068D0
public OrderedDictionary(IEqualityComparer equalityComparer)
{
this.list = new ArrayList();
this.hash = new Hashtable(equalityComparer);
this.comparer = equalityComparer;
}
/// Initializes a new instance of the class using the specified initial capacity and comparer.
/// The initial number of elements that the collection can contain.
/// The to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of .
// Token: 0x06000229 RID: 553 RVA: 0x00008704 File Offset: 0x00006904
public OrderedDictionary(int capacity, IEqualityComparer equalityComparer)
{
this.initialCapacity = ((capacity >= 0) ? capacity : 0);
this.list = new ArrayList(this.initialCapacity);
this.hash = new Hashtable(this.initialCapacity, equalityComparer);
this.comparer = equalityComparer;
}
/// Initializes a new instance of the class that is serializable using the specified and objects.
/// A object containing the information required to serialize the collection.
/// A object containing the source and destination of the serialized stream associated with the .
// Token: 0x0600022A RID: 554 RVA: 0x00008758 File Offset: 0x00006958
protected OrderedDictionary(SerializationInfo info, StreamingContext context)
{
this.serializationInfo = info;
}
/// Implements the interface and is called back by the deserialization event when deserialization is complete.
/// The source of the deserialization event.
// Token: 0x0600022B RID: 555 RVA: 0x00008768 File Offset: 0x00006968
void IDeserializationCallback.OnDeserialization(object sender)
{
if (this.serializationInfo == null)
{
return;
}
this.comparer = (IEqualityComparer)this.serializationInfo.GetValue("KeyComparer", typeof(IEqualityComparer));
this.readOnly = this.serializationInfo.GetBoolean("ReadOnly");
this.initialCapacity = this.serializationInfo.GetInt32("InitialCapacity");
if (this.list == null)
{
this.list = new ArrayList();
}
else
{
this.list.Clear();
}
this.hash = new Hashtable(this.comparer);
object[] array = (object[])this.serializationInfo.GetValue("ArrayList", typeof(object[]));
foreach (DictionaryEntry dictionaryEntry in array)
{
this.hash.Add(dictionaryEntry.Key, dictionaryEntry.Value);
this.list.Add(dictionaryEntry);
}
}
/// Returns an object that iterates through the collection.
/// An object for the collection.
// Token: 0x0600022C RID: 556 RVA: 0x00008874 File Offset: 0x00006A74
IEnumerator IEnumerable.GetEnumerator()
{
return this.list.GetEnumerator();
}
/// Gets a value indicating whether access to the object is synchronized (thread-safe).
/// This method always returns false.
// Token: 0x17000093 RID: 147
// (get) Token: 0x0600022D RID: 557 RVA: 0x00008884 File Offset: 0x00006A84
bool ICollection.IsSynchronized
{
get
{
return this.list.IsSynchronized;
}
}
/// Gets an object that can be used to synchronize access to the object.
/// An object that can be used to synchronize access to the object.
// Token: 0x17000094 RID: 148
// (get) Token: 0x0600022E RID: 558 RVA: 0x00008894 File Offset: 0x00006A94
object ICollection.SyncRoot
{
get
{
return this.list.SyncRoot;
}
}
/// Gets a value indicating whether the has a fixed size.
/// true if the has a fixed size; otherwise, false. The default is false.
// Token: 0x17000095 RID: 149
// (get) Token: 0x0600022F RID: 559 RVA: 0x000088A4 File Offset: 0x00006AA4
bool IDictionary.IsFixedSize
{
get
{
return false;
}
}
/// Implements the interface and is called back by the deserialization event when deserialization is complete.
/// The source of the deserialization event.
/// The object associated with the current collection is invalid.
// Token: 0x06000230 RID: 560 RVA: 0x000088A8 File Offset: 0x00006AA8
protected virtual void OnDeserialization(object sender)
{
((IDeserializationCallback)this).OnDeserialization(sender);
}
/// Implements the interface and returns the data needed to serialize the collection.
/// A object containing the information required to serialize the collection.
/// A object containing the source and destination of the serialized stream associated with the .
///
/// is null.
// Token: 0x06000231 RID: 561 RVA: 0x000088B4 File Offset: 0x00006AB4
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
info.AddValue("KeyComparer", this.comparer, typeof(IEqualityComparer));
info.AddValue("ReadOnly", this.readOnly);
info.AddValue("InitialCapacity", this.initialCapacity);
object[] array = new object[this.hash.Count];
this.hash.CopyTo(array, 0);
info.AddValue("ArrayList", array);
}
/// Gets the number of key/values pairs contained in the collection.
/// The number of key/value pairs contained in the collection.
// Token: 0x17000096 RID: 150
// (get) Token: 0x06000232 RID: 562 RVA: 0x0000893C File Offset: 0x00006B3C
public int Count
{
get
{
return this.list.Count;
}
}
/// Copies the elements to a one-dimensional object at the specified index.
/// The one-dimensional object that is the destination of the objects copied from collection. The must have zero-based indexing.
/// The zero-based index in at which copying begins.
// Token: 0x06000233 RID: 563 RVA: 0x0000894C File Offset: 0x00006B4C
public void CopyTo(Array array, int index)
{
this.list.CopyTo(array, index);
}
/// Gets a value indicating whether the collection is read-only.
/// true if the collection is read-only; otherwise, false. The default is false.
// Token: 0x17000097 RID: 151
// (get) Token: 0x06000234 RID: 564 RVA: 0x0000895C File Offset: 0x00006B5C
public bool IsReadOnly
{
get
{
return this.readOnly;
}
}
/// Gets or sets the value with the specified key.
/// The value associated with the specified key. If the specified key is not found, attempting to get it returns null, and attempting to set it creates a new element using the specified key.
/// The key of the value to get or set.
/// The property is being set and the collection is read-only.
// Token: 0x17000098 RID: 152
public object this[object key]
{
get
{
return this.hash[key];
}
set
{
this.WriteCheck();
if (this.hash.Contains(key))
{
int num = this.FindListEntry(key);
this.list[num] = new DictionaryEntry(key, value);
}
else
{
this.list.Add(new DictionaryEntry(key, value));
}
this.hash[key] = value;
}
}
/// Gets or sets the value at the specified index.
/// The value of the item at the specified index.
/// The zero-based index of the value to get or set.
/// The property is being set and the collection is read-only.
///
/// is less than zero.-or- is equal to or greater than .
// Token: 0x17000099 RID: 153
public object this[int index]
{
get
{
return ((DictionaryEntry)this.list[index]).Value;
}
set
{
this.WriteCheck();
DictionaryEntry dictionaryEntry = (DictionaryEntry)this.list[index];
dictionaryEntry.Value = value;
this.list[index] = dictionaryEntry;
this.hash[dictionaryEntry.Key] = value;
}
}
/// Gets an object containing the keys in the collection.
/// An object containing the keys in the collection.
// Token: 0x1700009A RID: 154
// (get) Token: 0x06000239 RID: 569 RVA: 0x00008A60 File Offset: 0x00006C60
public ICollection Keys
{
get
{
return new OrderedDictionary.OrderedCollection(this.list, true);
}
}
/// Gets an object containing the values in the collection.
/// An object containing the values in the collection.
// Token: 0x1700009B RID: 155
// (get) Token: 0x0600023A RID: 570 RVA: 0x00008A70 File Offset: 0x00006C70
public ICollection Values
{
get
{
return new OrderedDictionary.OrderedCollection(this.list, false);
}
}
/// Adds an entry with the specified key and value into the collection with the lowest available index.
/// The key of the entry to add.
/// The value of the entry to add. This value can be null.
/// The collection is read-only.
// Token: 0x0600023B RID: 571 RVA: 0x00008A80 File Offset: 0x00006C80
public void Add(object key, object value)
{
this.WriteCheck();
this.hash.Add(key, value);
this.list.Add(new DictionaryEntry(key, value));
}
/// Removes all elements from the collection.
/// The collection is read-only.
// Token: 0x0600023C RID: 572 RVA: 0x00008AB0 File Offset: 0x00006CB0
public void Clear()
{
this.WriteCheck();
this.hash.Clear();
this.list.Clear();
}
/// Determines whether the collection contains a specific key.
/// true if the collection contains an element with the specified key; otherwise, false.
/// The key to locate in the collection.
// Token: 0x0600023D RID: 573 RVA: 0x00008AD0 File Offset: 0x00006CD0
public bool Contains(object key)
{
return this.hash.Contains(key);
}
/// Returns an object that iterates through the collection.
/// An object for the collection.
// Token: 0x0600023E RID: 574 RVA: 0x00008AE0 File Offset: 0x00006CE0
public virtual IDictionaryEnumerator GetEnumerator()
{
return new OrderedDictionary.OrderedEntryCollectionEnumerator(this.list.GetEnumerator());
}
/// Removes the entry with the specified key from the collection.
/// The key of the entry to remove.
/// The collection is read-only.
///
/// is null.
// Token: 0x0600023F RID: 575 RVA: 0x00008AF4 File Offset: 0x00006CF4
public void Remove(object key)
{
this.WriteCheck();
if (this.hash.Contains(key))
{
this.hash.Remove(key);
int num = this.FindListEntry(key);
this.list.RemoveAt(num);
}
}
// Token: 0x06000240 RID: 576 RVA: 0x00008B38 File Offset: 0x00006D38
private int FindListEntry(object key)
{
for (int i = 0; i < this.list.Count; i++)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)this.list[i];
if ((this.comparer == null) ? dictionaryEntry.Key.Equals(key) : this.comparer.Equals(dictionaryEntry.Key, key))
{
return i;
}
}
return -1;
}
// Token: 0x06000241 RID: 577 RVA: 0x00008BAC File Offset: 0x00006DAC
private void WriteCheck()
{
if (this.readOnly)
{
throw new NotSupportedException("Collection is read only");
}
}
/// Returns a read-only copy of the current collection.
/// A read-only copy of the current collection.
// Token: 0x06000242 RID: 578 RVA: 0x00008BC4 File Offset: 0x00006DC4
public OrderedDictionary AsReadOnly()
{
return new OrderedDictionary
{
list = this.list,
hash = this.hash,
comparer = this.comparer,
readOnly = true
};
}
/// Inserts a new entry into the collection with the specified key and value at the specified index.
/// The zero-based index at which the element should be inserted.
/// The key of the entry to add.
/// The value of the entry to add. The value can be null.
///
/// is out of range.
/// This collection is read-only.
// Token: 0x06000243 RID: 579 RVA: 0x00008C04 File Offset: 0x00006E04
public void Insert(int index, object key, object value)
{
this.WriteCheck();
this.hash.Add(key, value);
this.list.Insert(index, new DictionaryEntry(key, value));
}
/// Removes the entry at the specified index from the collection.
/// The zero-based index of the entry to remove.
/// The collection is read-only.
///
/// is less than zero.- or - is equal to or greater than .
// Token: 0x06000244 RID: 580 RVA: 0x00008C3C File Offset: 0x00006E3C
public void RemoveAt(int index)
{
this.WriteCheck();
DictionaryEntry dictionaryEntry = (DictionaryEntry)this.list[index];
this.list.RemoveAt(index);
this.hash.Remove(dictionaryEntry.Key);
}
// Token: 0x040000A6 RID: 166
private ArrayList list;
// Token: 0x040000A7 RID: 167
private Hashtable hash;
// Token: 0x040000A8 RID: 168
private bool readOnly;
// Token: 0x040000A9 RID: 169
private int initialCapacity;
// Token: 0x040000AA RID: 170
private SerializationInfo serializationInfo;
// Token: 0x040000AB RID: 171
private IEqualityComparer comparer;
// Token: 0x02000035 RID: 53
private class OrderedEntryCollectionEnumerator : IEnumerator, IDictionaryEnumerator
{
// Token: 0x06000245 RID: 581 RVA: 0x00008C80 File Offset: 0x00006E80
public OrderedEntryCollectionEnumerator(IEnumerator listEnumerator)
{
this.listEnumerator = listEnumerator;
}
// Token: 0x06000246 RID: 582 RVA: 0x00008C90 File Offset: 0x00006E90
public bool MoveNext()
{
return this.listEnumerator.MoveNext();
}
// Token: 0x06000247 RID: 583 RVA: 0x00008CA0 File Offset: 0x00006EA0
public void Reset()
{
this.listEnumerator.Reset();
}
// Token: 0x1700009C RID: 156
// (get) Token: 0x06000248 RID: 584 RVA: 0x00008CB0 File Offset: 0x00006EB0
public object Current
{
get
{
return this.listEnumerator.Current;
}
}
// Token: 0x1700009D RID: 157
// (get) Token: 0x06000249 RID: 585 RVA: 0x00008CC0 File Offset: 0x00006EC0
public DictionaryEntry Entry
{
get
{
return (DictionaryEntry)this.listEnumerator.Current;
}
}
// Token: 0x1700009E RID: 158
// (get) Token: 0x0600024A RID: 586 RVA: 0x00008CD4 File Offset: 0x00006ED4
public object Key
{
get
{
return this.Entry.Key;
}
}
// Token: 0x1700009F RID: 159
// (get) Token: 0x0600024B RID: 587 RVA: 0x00008CF0 File Offset: 0x00006EF0
public object Value
{
get
{
return this.Entry.Value;
}
}
// Token: 0x040000AC RID: 172
private IEnumerator listEnumerator;
}
// Token: 0x02000036 RID: 54
private class OrderedCollection : ICollection, IEnumerable
{
// Token: 0x0600024C RID: 588 RVA: 0x00008D0C File Offset: 0x00006F0C
public OrderedCollection(ArrayList list, bool isKeyList)
{
this.list = list;
this.isKeyList = isKeyList;
}
// Token: 0x170000A0 RID: 160
// (get) Token: 0x0600024D RID: 589 RVA: 0x00008D24 File Offset: 0x00006F24
public int Count
{
get
{
return this.list.Count;
}
}
// Token: 0x170000A1 RID: 161
// (get) Token: 0x0600024E RID: 590 RVA: 0x00008D34 File Offset: 0x00006F34
public bool IsSynchronized
{
get
{
return false;
}
}
// Token: 0x170000A2 RID: 162
// (get) Token: 0x0600024F RID: 591 RVA: 0x00008D38 File Offset: 0x00006F38
public object SyncRoot
{
get
{
return this.list.SyncRoot;
}
}
// Token: 0x06000250 RID: 592 RVA: 0x00008D48 File Offset: 0x00006F48
public void CopyTo(Array array, int index)
{
for (int i = 0; i < this.list.Count; i++)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)this.list[i];
if (this.isKeyList)
{
array.SetValue(dictionaryEntry.Key, index + i);
}
else
{
array.SetValue(dictionaryEntry.Value, index + i);
}
}
}
// Token: 0x06000251 RID: 593 RVA: 0x00008DB4 File Offset: 0x00006FB4
public IEnumerator GetEnumerator()
{
return new OrderedDictionary.OrderedCollection.OrderedCollectionEnumerator(this.list.GetEnumerator(), this.isKeyList);
}
// Token: 0x040000AD RID: 173
private ArrayList list;
// Token: 0x040000AE RID: 174
private bool isKeyList;
// Token: 0x02000037 RID: 55
private class OrderedCollectionEnumerator : IEnumerator
{
// Token: 0x06000252 RID: 594 RVA: 0x00008DCC File Offset: 0x00006FCC
public OrderedCollectionEnumerator(IEnumerator listEnumerator, bool isKeyList)
{
this.listEnumerator = listEnumerator;
this.isKeyList = isKeyList;
}
// Token: 0x170000A3 RID: 163
// (get) Token: 0x06000253 RID: 595 RVA: 0x00008DE4 File Offset: 0x00006FE4
public object Current
{
get
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)this.listEnumerator.Current;
return (!this.isKeyList) ? dictionaryEntry.Value : dictionaryEntry.Key;
}
}
// Token: 0x06000254 RID: 596 RVA: 0x00008E20 File Offset: 0x00007020
public bool MoveNext()
{
return this.listEnumerator.MoveNext();
}
// Token: 0x06000255 RID: 597 RVA: 0x00008E30 File Offset: 0x00007030
public void Reset()
{
this.listEnumerator.Reset();
}
// Token: 0x040000AF RID: 175
private bool isKeyList;
// Token: 0x040000B0 RID: 176
private IEnumerator listEnumerator;
}
}
}
}