using System; using System.Runtime.Serialization; using System.Text; namespace System.Collections.Specialized { /// Represents a collection of associated keys and values that can be accessed either with the key or with the index. // Token: 0x02000033 RID: 51 [Serializable] public class NameValueCollection : NameObjectCollectionBase { /// Initializes a new instance of the class that is empty, has the default initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer. // Token: 0x06000209 RID: 521 RVA: 0x000080C0 File Offset: 0x000062C0 public NameValueCollection() { } /// Initializes a new instance of the class that is empty, has the specified initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer. /// The initial number of entries that the can contain. /// /// is less than zero. // Token: 0x0600020A RID: 522 RVA: 0x000080C8 File Offset: 0x000062C8 public NameValueCollection(int capacity) : base(capacity) { } /// Copies the entries from the specified to a new with the same initial capacity as the number of entries copied and using the same hash code provider and the same comparer as the source collection. /// The to copy to the new instance. /// /// is null. // Token: 0x0600020B RID: 523 RVA: 0x000080D4 File Offset: 0x000062D4 public NameValueCollection(NameValueCollection col) { IEqualityComparer equalityComparer2; if (col == null) { IEqualityComparer equalityComparer = null; equalityComparer2 = equalityComparer; } else { equalityComparer2 = col.EqualityComparer; } IComparer comparer2; if (col == null) { IComparer comparer = null; comparer2 = comparer; } else { comparer2 = col.Comparer; } IHashCodeProvider hashCodeProvider2; if (col == null) { IHashCodeProvider hashCodeProvider = null; hashCodeProvider2 = hashCodeProvider; } else { hashCodeProvider2 = col.HashCodeProvider; } base..ctor(equalityComparer2, comparer2, hashCodeProvider2); if (col == null) { throw new ArgumentNullException("col"); } this.Add(col); } /// Initializes a new instance of the class that is empty, has the default initial capacity and uses the specified hash code provider and the specified comparer. /// The that will supply the hash codes for all keys in the . /// The to use to determine whether two keys are equal. // Token: 0x0600020C RID: 524 RVA: 0x0000813C File Offset: 0x0000633C [Obsolete("Use NameValueCollection (IEqualityComparer)")] public NameValueCollection(IHashCodeProvider hashProvider, IComparer comparer) : base(hashProvider, comparer) { } /// Copies the entries from the specified to a new with the specified initial capacity or the same initial capacity as the number of entries copied, whichever is greater, and using the default case-insensitive hash code provider and the default case-insensitive comparer. /// The initial number of entries that the can contain. /// The to copy to the new instance. /// /// is less than zero. /// /// is null. // Token: 0x0600020D RID: 525 RVA: 0x00008148 File Offset: 0x00006348 public NameValueCollection(int capacity, NameValueCollection col) { IHashCodeProvider hashCodeProvider2; if (col == null) { IHashCodeProvider hashCodeProvider = null; hashCodeProvider2 = hashCodeProvider; } else { hashCodeProvider2 = col.HashCodeProvider; } IComparer comparer2; if (col == null) { IComparer comparer = null; comparer2 = comparer; } else { comparer2 = col.Comparer; } base..ctor(capacity, hashCodeProvider2, comparer2); this.Add(col); } /// Initializes a new instance of the class that is serializable and uses the specified and . /// A object that contains the information required to serialize the new instance. /// A object that contains the source and destination of the serialized stream associated with the new instance. // Token: 0x0600020E RID: 526 RVA: 0x0000818C File Offset: 0x0000638C protected NameValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } /// Initializes a new instance of the class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer. /// The initial number of entries that the can contain. /// The that will supply the hash codes for all keys in the . /// The to use to determine whether two keys are equal. /// /// is less than zero. // Token: 0x0600020F RID: 527 RVA: 0x00008198 File Offset: 0x00006398 [Obsolete("Use NameValueCollection (IEqualityComparer)")] public NameValueCollection(int capacity, IHashCodeProvider hashProvider, IComparer comparer) : base(capacity, hashProvider, comparer) { } /// Initializes a new instance of the class that is empty, has the default initial capacity, and uses the specified object. /// The object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection. // Token: 0x06000210 RID: 528 RVA: 0x000081A4 File Offset: 0x000063A4 public NameValueCollection(IEqualityComparer equalityComparer) : base(equalityComparer) { } /// Initializes a new instance of the class that is empty, has the specified initial capacity, and uses the specified object. /// The initial number of entries that the object can contain. /// The object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection. /// /// is less than zero. // Token: 0x06000211 RID: 529 RVA: 0x000081B0 File Offset: 0x000063B0 public NameValueCollection(int capacity, IEqualityComparer equalityComparer) : base(capacity, equalityComparer) { } /// Gets all the keys in the . /// A array that contains all the keys of the . // Token: 0x17000090 RID: 144 // (get) Token: 0x06000212 RID: 530 RVA: 0x000081BC File Offset: 0x000063BC public virtual string[] AllKeys { get { if (this.cachedAllKeys == null) { this.cachedAllKeys = base.BaseGetAllKeys(); } return this.cachedAllKeys; } } /// Gets the entry at the specified index of the . /// A that contains the comma-separated list of values at the specified index of the collection. /// The zero-based index of the entry to locate in the collection. /// /// is outside the valid range of indexes for the collection. // Token: 0x17000091 RID: 145 public string this[int index] { get { return this.Get(index); } } /// Gets or sets the entry with the specified key in the . /// A that contains the comma-separated list of values associated with the specified key, if found; otherwise, null. /// The key of the entry to locate. The key can be null. /// The collection is read-only and the operation attempts to modify the collection. // Token: 0x17000092 RID: 146 public string this[string name] { get { return this.Get(name); } set { this.Set(name, value); } } /// Copies the entries in the specified to the current . /// The to copy to the current . /// The collection is read-only. /// /// is null. // Token: 0x06000216 RID: 534 RVA: 0x00008200 File Offset: 0x00006400 public void Add(NameValueCollection c) { if (base.IsReadOnly) { throw new NotSupportedException("Collection is read-only"); } if (c == null) { throw new ArgumentNullException("c"); } this.InvalidateCachedArrays(); int count = c.Count; for (int i = 0; i < count; i++) { string key = c.GetKey(i); ArrayList arrayList = (ArrayList)c.BaseGet(i); ArrayList arrayList2 = (ArrayList)base.BaseGet(key); if (arrayList2 != null && arrayList != null) { arrayList2.AddRange(arrayList); } else if (arrayList != null) { arrayList2 = new ArrayList(arrayList); } base.BaseSet(key, arrayList2); } } /// Adds an entry with the specified name and value to the . /// The key of the entry to add. The key can be null. /// The value of the entry to add. The value can be null. /// The collection is read-only. // Token: 0x06000217 RID: 535 RVA: 0x000082A8 File Offset: 0x000064A8 public virtual void Add(string name, string val) { if (base.IsReadOnly) { throw new NotSupportedException("Collection is read-only"); } this.InvalidateCachedArrays(); ArrayList arrayList = (ArrayList)base.BaseGet(name); if (arrayList == null) { arrayList = new ArrayList(); if (val != null) { arrayList.Add(val); } base.BaseAdd(name, arrayList); } else if (val != null) { arrayList.Add(val); } } /// Invalidates the cached arrays and removes all entries from the . /// The collection is read-only. /// /// /// // Token: 0x06000218 RID: 536 RVA: 0x00008314 File Offset: 0x00006514 public virtual void Clear() { if (base.IsReadOnly) { throw new NotSupportedException("Collection is read-only"); } this.InvalidateCachedArrays(); base.BaseClear(); } /// Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. /// The one-dimensional that is the destination of the elements 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: 0x06000219 RID: 537 RVA: 0x00008344 File Offset: 0x00006544 public void CopyTo(Array dest, int index) { if (dest == null) { throw new ArgumentNullException("dest", "Null argument - dest"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", "index is less than 0"); } if (dest.Rank > 1) { throw new ArgumentException("dest", "multidim"); } if (this.cachedAll == null) { this.RefreshCachedAll(); } try { this.cachedAll.CopyTo(dest, index); } catch (ArrayTypeMismatchException) { throw new InvalidCastException(); } } // Token: 0x0600021A RID: 538 RVA: 0x000083E8 File Offset: 0x000065E8 private void RefreshCachedAll() { this.cachedAll = null; int count = this.Count; this.cachedAll = new string[count]; for (int i = 0; i < count; i++) { this.cachedAll[i] = this.Get(i); } } /// Gets the values at the specified index of the combined into one comma-separated list. /// A that contains a comma-separated list of the values at the specified index of the , if found; otherwise, null. /// The zero-based index of the entry that contains the values to get from the collection. /// /// is outside the valid range of indexes for the collection. // Token: 0x0600021B RID: 539 RVA: 0x00008430 File Offset: 0x00006630 public virtual string Get(int index) { ArrayList arrayList = (ArrayList)base.BaseGet(index); return NameValueCollection.AsSingleString(arrayList); } /// Gets the values associated with the specified key from the combined into one comma-separated list. /// A that contains a comma-separated list of the values associated with the specified key from the , if found; otherwise, null. /// The key of the entry that contains the values to get. The key can be null. // Token: 0x0600021C RID: 540 RVA: 0x00008450 File Offset: 0x00006650 public virtual string Get(string name) { ArrayList arrayList = (ArrayList)base.BaseGet(name); return NameValueCollection.AsSingleString(arrayList); } // Token: 0x0600021D RID: 541 RVA: 0x00008470 File Offset: 0x00006670 private static string AsSingleString(ArrayList values) { if (values == null) { return null; } int count = values.Count; switch (count) { case 0: return null; case 1: return (string)values[0]; case 2: return (string)values[0] + ',' + (string)values[1]; default: { int num = count; for (int i = 0; i < count; i++) { num += ((string)values[i]).Length; } StringBuilder stringBuilder = new StringBuilder((string)values[0], num); for (int j = 1; j < count; j++) { stringBuilder.Append(','); stringBuilder.Append(values[j]); } return stringBuilder.ToString(); } } } /// Gets the key at the specified index of the . /// A that contains the key at the specified index of the , if found; otherwise, null. /// The zero-based index of the key to get from the collection. /// /// is outside the valid range of indexes for the collection. // Token: 0x0600021E RID: 542 RVA: 0x00008550 File Offset: 0x00006750 public virtual string GetKey(int index) { return base.BaseGetKey(index); } /// Gets the values at the specified index of the . /// A array that contains the values at the specified index of the , if found; otherwise, null. /// The zero-based index of the entry that contains the values to get from the collection. /// /// is outside the valid range of indexes for the collection. // Token: 0x0600021F RID: 543 RVA: 0x0000855C File Offset: 0x0000675C public virtual string[] GetValues(int index) { ArrayList arrayList = (ArrayList)base.BaseGet(index); return NameValueCollection.AsStringArray(arrayList); } /// Gets the values associated with the specified key from the . /// A array that contains the values associated with the specified key from the , if found; otherwise, null. /// The key of the entry that contains the values to get. The key can be null. // Token: 0x06000220 RID: 544 RVA: 0x0000857C File Offset: 0x0000677C public virtual string[] GetValues(string name) { ArrayList arrayList = (ArrayList)base.BaseGet(name); return NameValueCollection.AsStringArray(arrayList); } // Token: 0x06000221 RID: 545 RVA: 0x0000859C File Offset: 0x0000679C private static string[] AsStringArray(ArrayList values) { if (values == null) { return null; } int count = values.Count; if (count == 0) { return null; } string[] array = new string[count]; values.CopyTo(array); return array; } /// Gets a value indicating whether the contains keys that are not null. /// true if the contains keys that are not null; otherwise, false. // Token: 0x06000222 RID: 546 RVA: 0x000085D0 File Offset: 0x000067D0 public bool HasKeys() { return base.BaseHasKeys(); } /// Removes the entries with the specified key from the instance. /// The key of the entry to remove. The key can be null. /// The collection is read-only. // Token: 0x06000223 RID: 547 RVA: 0x000085D8 File Offset: 0x000067D8 public virtual void Remove(string name) { if (base.IsReadOnly) { throw new NotSupportedException("Collection is read-only"); } this.InvalidateCachedArrays(); base.BaseRemove(name); } /// Sets the value of an entry in the . /// The key of the entry to add the new value to. The key can be null. /// The that represents the new value to add to the specified entry. The value can be null. /// The collection is read-only. // Token: 0x06000224 RID: 548 RVA: 0x00008600 File Offset: 0x00006800 public virtual void Set(string name, string value) { if (base.IsReadOnly) { throw new NotSupportedException("Collection is read-only"); } this.InvalidateCachedArrays(); ArrayList arrayList = new ArrayList(); if (value != null) { arrayList.Add(value); base.BaseSet(name, arrayList); } else { base.BaseSet(name, null); } } /// Resets the cached arrays of the collection to null. // Token: 0x06000225 RID: 549 RVA: 0x00008654 File Offset: 0x00006854 protected void InvalidateCachedArrays() { this.cachedAllKeys = null; this.cachedAll = null; } // Token: 0x040000A4 RID: 164 private string[] cachedAllKeys; // Token: 0x040000A5 RID: 165 private string[] cachedAll; } }