using System; namespace System.Collections.Specialized { /// Implements IDictionary using a singly linked list. Recommended for collections that typically contain 10 items or less. // Token: 0x0200002A RID: 42 [Serializable] public class ListDictionary : ICollection, IDictionary, IEnumerable { /// Creates an empty using the default comparer. // Token: 0x060001AE RID: 430 RVA: 0x00006F10 File Offset: 0x00005110 public ListDictionary() { this.count = 0; this.version = 0; this.comparer = null; this.head = null; } /// Creates an empty 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: 0x060001AF RID: 431 RVA: 0x00006F40 File Offset: 0x00005140 public ListDictionary(IComparer comparer) : this() { this.comparer = comparer; } /// Returns an that iterates through the . /// An for the . // Token: 0x060001B0 RID: 432 RVA: 0x00006F50 File Offset: 0x00005150 IEnumerator IEnumerable.GetEnumerator() { return new ListDictionary.DictionaryNodeEnumerator(this); } // Token: 0x060001B1 RID: 433 RVA: 0x00006F58 File Offset: 0x00005158 private ListDictionary.DictionaryNode FindEntry(object key) { if (key == null) { throw new ArgumentNullException("key", "Attempted lookup for a null key."); } ListDictionary.DictionaryNode dictionaryNode = this.head; if (this.comparer == null) { while (dictionaryNode != null) { if (key.Equals(dictionaryNode.key)) { break; } dictionaryNode = dictionaryNode.next; } } else { while (dictionaryNode != null) { if (this.comparer.Compare(key, dictionaryNode.key) == 0) { break; } dictionaryNode = dictionaryNode.next; } } return dictionaryNode; } // Token: 0x060001B2 RID: 434 RVA: 0x00006FEC File Offset: 0x000051EC private ListDictionary.DictionaryNode FindEntry(object key, out ListDictionary.DictionaryNode prev) { if (key == null) { throw new ArgumentNullException("key", "Attempted lookup for a null key."); } ListDictionary.DictionaryNode dictionaryNode = this.head; prev = null; if (this.comparer == null) { while (dictionaryNode != null) { if (key.Equals(dictionaryNode.key)) { break; } prev = dictionaryNode; dictionaryNode = dictionaryNode.next; } } else { while (dictionaryNode != null) { if (this.comparer.Compare(key, dictionaryNode.key) == 0) { break; } prev = dictionaryNode; dictionaryNode = dictionaryNode.next; } } return dictionaryNode; } // Token: 0x060001B3 RID: 435 RVA: 0x00007088 File Offset: 0x00005288 private void AddImpl(object key, object value, ListDictionary.DictionaryNode prev) { if (prev == null) { this.head = new ListDictionary.DictionaryNode(key, value, this.head); } else { prev.next = new ListDictionary.DictionaryNode(key, value, prev.next); } this.count++; this.version++; } /// Gets the number of key/value pairs contained in the . /// The number of key/value pairs contained in the . // Token: 0x17000072 RID: 114 // (get) Token: 0x060001B4 RID: 436 RVA: 0x000070E4 File Offset: 0x000052E4 public int Count { get { return this.count; } } /// Gets a value indicating whether the is synchronized (thread safe). /// This property always returns false. // Token: 0x17000073 RID: 115 // (get) Token: 0x060001B5 RID: 437 RVA: 0x000070EC File Offset: 0x000052EC public bool IsSynchronized { get { return false; } } /// Gets an object that can be used to synchronize access to the . /// An object that can be used to synchronize access to the . // Token: 0x17000074 RID: 116 // (get) Token: 0x060001B6 RID: 438 RVA: 0x000070F0 File Offset: 0x000052F0 public object SyncRoot { get { return this; } } /// Copies the entries to a one-dimensional instance at the specified index. /// The one-dimensional that is the destination of the objects copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// /// is multidimensional.-or- The number of elements in the source is greater than the available space from to the end of the destination . /// The type of the source cannot be cast automatically to the type of the destination . // Token: 0x060001B7 RID: 439 RVA: 0x000070F4 File Offset: 0x000052F4 public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array", "Array cannot be null."); } if (index < 0) { throw new ArgumentOutOfRangeException("index", "index is less than 0"); } if (index > array.Length) { throw new IndexOutOfRangeException("index is too large"); } if (this.Count > array.Length - index) { throw new ArgumentException("Not enough room in the array"); } foreach (object obj in this) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; array.SetValue(dictionaryEntry, index++); } } /// Gets a value indicating whether the has a fixed size. /// This property always returns false. // Token: 0x17000075 RID: 117 // (get) Token: 0x060001B8 RID: 440 RVA: 0x000071CC File Offset: 0x000053CC public bool IsFixedSize { get { return false; } } /// Gets a value indicating whether the is read-only. /// This property always returns false. // Token: 0x17000076 RID: 118 // (get) Token: 0x060001B9 RID: 441 RVA: 0x000071D0 File Offset: 0x000053D0 public bool IsReadOnly { get { return false; } } /// Gets or sets the value associated 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 entry using the specified key. /// The key whose value to get or set. /// /// is null. // Token: 0x17000077 RID: 119 public object this[object key] { get { ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key); return (dictionaryNode != null) ? dictionaryNode.value : null; } set { ListDictionary.DictionaryNode dictionaryNode2; ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out dictionaryNode2); if (dictionaryNode != null) { dictionaryNode.value = value; } else { this.AddImpl(key, value, dictionaryNode2); } } } /// Gets an containing the keys in the . /// An containing the keys in the . // Token: 0x17000078 RID: 120 // (get) Token: 0x060001BC RID: 444 RVA: 0x00007230 File Offset: 0x00005430 public ICollection Keys { get { return new ListDictionary.DictionaryNodeCollection(this, true); } } /// Gets an containing the values in the . /// An containing the values in the . // Token: 0x17000079 RID: 121 // (get) Token: 0x060001BD RID: 445 RVA: 0x0000723C File Offset: 0x0000543C public ICollection Values { get { return new ListDictionary.DictionaryNodeCollection(this, false); } } /// Adds an entry with the specified key and value into the . /// The key of the entry to add. /// The value of the entry to add. The value can be null. /// /// is null. /// An entry with the same key already exists in the . // Token: 0x060001BE RID: 446 RVA: 0x00007248 File Offset: 0x00005448 public void Add(object key, object value) { ListDictionary.DictionaryNode dictionaryNode2; ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out dictionaryNode2); if (dictionaryNode != null) { throw new ArgumentException("key", "Duplicate key in add."); } this.AddImpl(key, value, dictionaryNode2); } /// Removes all entries from the . // Token: 0x060001BF RID: 447 RVA: 0x00007280 File Offset: 0x00005480 public void Clear() { this.head = null; this.count = 0; this.version++; } /// Determines whether the contains a specific key. /// true if the contains an entry with the specified key; otherwise, false. /// The key to locate in the . /// /// is null. // Token: 0x060001C0 RID: 448 RVA: 0x000072A0 File Offset: 0x000054A0 public bool Contains(object key) { return this.FindEntry(key) != null; } /// Returns an that iterates through the . /// An for the . // Token: 0x060001C1 RID: 449 RVA: 0x000072B0 File Offset: 0x000054B0 public IDictionaryEnumerator GetEnumerator() { return new ListDictionary.DictionaryNodeEnumerator(this); } /// Removes the entry with the specified key from the . /// The key of the entry to remove. /// /// is null. // Token: 0x060001C2 RID: 450 RVA: 0x000072B8 File Offset: 0x000054B8 public void Remove(object key) { ListDictionary.DictionaryNode dictionaryNode2; ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out dictionaryNode2); if (dictionaryNode == null) { return; } if (dictionaryNode2 == null) { this.head = dictionaryNode.next; } else { dictionaryNode2.next = dictionaryNode.next; } dictionaryNode.value = null; this.count--; this.version++; } // Token: 0x04000086 RID: 134 private int count; // Token: 0x04000087 RID: 135 private int version; // Token: 0x04000088 RID: 136 private ListDictionary.DictionaryNode head; // Token: 0x04000089 RID: 137 private IComparer comparer; // Token: 0x0200002B RID: 43 [Serializable] private class DictionaryNode { // Token: 0x060001C3 RID: 451 RVA: 0x0000731C File Offset: 0x0000551C public DictionaryNode(object key, object value, ListDictionary.DictionaryNode next) { this.key = key; this.value = value; this.next = next; } // Token: 0x0400008A RID: 138 public object key; // Token: 0x0400008B RID: 139 public object value; // Token: 0x0400008C RID: 140 public ListDictionary.DictionaryNode next; } // Token: 0x0200002C RID: 44 private class DictionaryNodeEnumerator : IEnumerator, IDictionaryEnumerator { // Token: 0x060001C4 RID: 452 RVA: 0x0000733C File Offset: 0x0000553C public DictionaryNodeEnumerator(ListDictionary dict) { this.dict = dict; this.version = dict.version; this.Reset(); } // Token: 0x060001C5 RID: 453 RVA: 0x00007360 File Offset: 0x00005560 private void FailFast() { if (this.version != this.dict.version) { throw new InvalidOperationException("The ListDictionary's contents changed after this enumerator was instantiated."); } } // Token: 0x060001C6 RID: 454 RVA: 0x00007384 File Offset: 0x00005584 public bool MoveNext() { this.FailFast(); if (this.current == null && !this.isAtStart) { return false; } this.current = ((!this.isAtStart) ? this.current.next : this.dict.head); this.isAtStart = false; return this.current != null; } // Token: 0x060001C7 RID: 455 RVA: 0x000073F0 File Offset: 0x000055F0 public void Reset() { this.FailFast(); this.isAtStart = true; this.current = null; } // Token: 0x1700007A RID: 122 // (get) Token: 0x060001C8 RID: 456 RVA: 0x00007408 File Offset: 0x00005608 public object Current { get { return this.Entry; } } // Token: 0x1700007B RID: 123 // (get) Token: 0x060001C9 RID: 457 RVA: 0x00007418 File Offset: 0x00005618 private ListDictionary.DictionaryNode DictionaryNode { get { this.FailFast(); if (this.current == null) { throw new InvalidOperationException("Enumerator is positioned before the collection's first element or after the last element."); } return this.current; } } // Token: 0x1700007C RID: 124 // (get) Token: 0x060001CA RID: 458 RVA: 0x00007448 File Offset: 0x00005648 public DictionaryEntry Entry { get { object key = this.DictionaryNode.key; return new DictionaryEntry(key, this.current.value); } } // Token: 0x1700007D RID: 125 // (get) Token: 0x060001CB RID: 459 RVA: 0x00007474 File Offset: 0x00005674 public object Key { get { return this.DictionaryNode.key; } } // Token: 0x1700007E RID: 126 // (get) Token: 0x060001CC RID: 460 RVA: 0x00007484 File Offset: 0x00005684 public object Value { get { return this.DictionaryNode.value; } } // Token: 0x0400008D RID: 141 private ListDictionary dict; // Token: 0x0400008E RID: 142 private bool isAtStart; // Token: 0x0400008F RID: 143 private ListDictionary.DictionaryNode current; // Token: 0x04000090 RID: 144 private int version; } // Token: 0x0200002D RID: 45 private class DictionaryNodeCollection : ICollection, IEnumerable { // Token: 0x060001CD RID: 461 RVA: 0x00007494 File Offset: 0x00005694 public DictionaryNodeCollection(ListDictionary dict, bool isKeyList) { this.dict = dict; this.isKeyList = isKeyList; } // Token: 0x1700007F RID: 127 // (get) Token: 0x060001CE RID: 462 RVA: 0x000074AC File Offset: 0x000056AC public int Count { get { return this.dict.Count; } } // Token: 0x17000080 RID: 128 // (get) Token: 0x060001CF RID: 463 RVA: 0x000074BC File Offset: 0x000056BC public bool IsSynchronized { get { return false; } } // Token: 0x17000081 RID: 129 // (get) Token: 0x060001D0 RID: 464 RVA: 0x000074C0 File Offset: 0x000056C0 public object SyncRoot { get { return this.dict.SyncRoot; } } // Token: 0x060001D1 RID: 465 RVA: 0x000074D0 File Offset: 0x000056D0 public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array", "Array cannot be null."); } if (index < 0) { throw new ArgumentOutOfRangeException("index", "index is less than 0"); } if (index > array.Length) { throw new IndexOutOfRangeException("index is too large"); } if (this.Count > array.Length - index) { throw new ArgumentException("Not enough room in the array"); } foreach (object obj in this) { array.SetValue(obj, index++); } } // Token: 0x060001D2 RID: 466 RVA: 0x000075A0 File Offset: 0x000057A0 public IEnumerator GetEnumerator() { return new ListDictionary.DictionaryNodeCollection.DictionaryNodeCollectionEnumerator(this.dict.GetEnumerator(), this.isKeyList); } // Token: 0x04000091 RID: 145 private ListDictionary dict; // Token: 0x04000092 RID: 146 private bool isKeyList; // Token: 0x0200002E RID: 46 private class DictionaryNodeCollectionEnumerator : IEnumerator { // Token: 0x060001D3 RID: 467 RVA: 0x000075B8 File Offset: 0x000057B8 public DictionaryNodeCollectionEnumerator(IDictionaryEnumerator inner, bool isKeyList) { this.inner = inner; this.isKeyList = isKeyList; } // Token: 0x17000082 RID: 130 // (get) Token: 0x060001D4 RID: 468 RVA: 0x000075D0 File Offset: 0x000057D0 public object Current { get { return (!this.isKeyList) ? this.inner.Value : this.inner.Key; } } // Token: 0x060001D5 RID: 469 RVA: 0x00007604 File Offset: 0x00005804 public bool MoveNext() { return this.inner.MoveNext(); } // Token: 0x060001D6 RID: 470 RVA: 0x00007614 File Offset: 0x00005814 public void Reset() { this.inner.Reset(); } // Token: 0x04000093 RID: 147 private IDictionaryEnumerator inner; // Token: 0x04000094 RID: 148 private bool isKeyList; } } } }