using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
namespace System.Net
{
/// Provides a collection container for instances of the class.
// Token: 0x02000206 RID: 518
[Serializable]
public sealed class CookieCollection : ICollection, IEnumerable
{
// Token: 0x170005C8 RID: 1480
// (get) Token: 0x0600119C RID: 4508 RVA: 0x00033CD4 File Offset: 0x00031ED4
internal IList List
{
get
{
return this.list;
}
}
/// Gets the number of cookies contained in a .
/// The number of cookies contained in a .
// Token: 0x170005C9 RID: 1481
// (get) Token: 0x0600119D RID: 4509 RVA: 0x00033CDC File Offset: 0x00031EDC
public int Count
{
get
{
return this.list.Count;
}
}
/// Gets a value that indicates whether access to a is thread safe.
/// true if access to the is thread safe; otherwise, false. The default is false.
// Token: 0x170005CA RID: 1482
// (get) Token: 0x0600119E RID: 4510 RVA: 0x00033CEC File Offset: 0x00031EEC
public bool IsSynchronized
{
get
{
return false;
}
}
/// Gets an object that you can use to synchronize access to the .
/// An object that you can use to synchronize access to the .
// Token: 0x170005CB RID: 1483
// (get) Token: 0x0600119F RID: 4511 RVA: 0x00033CF0 File Offset: 0x00031EF0
public object SyncRoot
{
get
{
return this;
}
}
/// Copies the elements of a to an instance of the class, starting at a particular index.
/// The target to which the will be copied.
/// The zero-based index in the target where copying begins.
///
/// is null.
///
/// is less than zero.
///
/// is multidimensional.-or- The number of elements in this is greater than the available space from to the end of the destination .
/// The elements in this cannot be cast automatically to the type of the destination .
// Token: 0x060011A0 RID: 4512 RVA: 0x00033CF4 File Offset: 0x00031EF4
public void CopyTo(Array array, int index)
{
((ICollection)this.list).CopyTo(array, index);
}
/// Copies the elements of this to a array starting at the specified index of the target array.
/// The target array to which the will be copied.
/// The zero-based index in the target where copying begins.
///
/// is null.
///
/// is less than zero.
///
/// is multidimensional.-or- The number of elements in this is greater than the available space from to the end of the destination .
/// The elements in this cannot be cast automatically to the type of the destination .
// Token: 0x060011A1 RID: 4513 RVA: 0x00033D04 File Offset: 0x00031F04
public void CopyTo(Cookie[] array, int index)
{
this.list.CopyTo(array, index);
}
/// Gets an enumerator that can iterate through a .
/// An instance of an implementation of an interface that can iterate through a .
// Token: 0x060011A2 RID: 4514 RVA: 0x00033D14 File Offset: 0x00031F14
public IEnumerator GetEnumerator()
{
return this.list.GetEnumerator();
}
/// Gets a value that indicates whether a is read-only.
/// true if this is a read-only ; otherwise, false. The default is true.
// Token: 0x170005CC RID: 1484
// (get) Token: 0x060011A3 RID: 4515 RVA: 0x00033D28 File Offset: 0x00031F28
public bool IsReadOnly
{
get
{
return true;
}
}
/// Adds a to a .
/// The to be added to a .
///
/// is null.
// Token: 0x060011A4 RID: 4516 RVA: 0x00033D2C File Offset: 0x00031F2C
public void Add(Cookie cookie)
{
if (cookie == null)
{
throw new ArgumentNullException("cookie");
}
int num = this.SearchCookie(cookie);
if (num == -1)
{
this.list.Add(cookie);
}
else
{
this.list[num] = cookie;
}
}
// Token: 0x060011A5 RID: 4517 RVA: 0x00033D78 File Offset: 0x00031F78
internal void Sort()
{
if (this.list.Count > 0)
{
this.list.Sort(CookieCollection.Comparer);
}
}
// Token: 0x060011A6 RID: 4518 RVA: 0x00033D9C File Offset: 0x00031F9C
private int SearchCookie(Cookie cookie)
{
string name = cookie.Name;
string domain = cookie.Domain;
string path = cookie.Path;
for (int i = this.list.Count - 1; i >= 0; i--)
{
Cookie cookie2 = this.list[i];
if (cookie2.Version == cookie.Version)
{
if (string.Compare(domain, cookie2.Domain, true, CultureInfo.InvariantCulture) == 0)
{
if (string.Compare(name, cookie2.Name, true, CultureInfo.InvariantCulture) == 0)
{
if (string.Compare(path, cookie2.Path, true, CultureInfo.InvariantCulture) == 0)
{
return i;
}
}
}
}
}
return -1;
}
/// Adds the contents of a to the current instance.
/// The to be added.
///
/// is null.
// Token: 0x060011A7 RID: 4519 RVA: 0x00033E5C File Offset: 0x0003205C
public void Add(CookieCollection cookies)
{
if (cookies == null)
{
throw new ArgumentNullException("cookies");
}
foreach (object obj in cookies)
{
Cookie cookie = (Cookie)obj;
this.Add(cookie);
}
}
/// Gets the with a specific index from a .
/// A with a specific index from a .
/// The zero-based index of the to be found.
///
/// is less than 0 or is greater than or equal to .
// Token: 0x170005CD RID: 1485
public Cookie this[int index]
{
get
{
if (index < 0 || index >= this.list.Count)
{
throw new ArgumentOutOfRangeException("index");
}
return this.list[index];
}
}
/// Gets the with a specific name from a .
/// The with a specific name from a .
/// The name of the to be found.
///
/// is null.
// Token: 0x170005CE RID: 1486
public Cookie this[string name]
{
get
{
foreach (Cookie cookie in this.list)
{
if (string.Compare(cookie.Name, name, true, CultureInfo.InvariantCulture) == 0)
{
return cookie;
}
}
return null;
}
}
// Token: 0x04000F8A RID: 3978
private List list = new List();
// Token: 0x04000F8B RID: 3979
private static CookieCollection.CookieCollectionComparer Comparer = new CookieCollection.CookieCollectionComparer();
// Token: 0x02000207 RID: 519
private sealed class CookieCollectionComparer : IComparer
{
// Token: 0x060011AB RID: 4523 RVA: 0x00033F94 File Offset: 0x00032194
public int Compare(Cookie x, Cookie y)
{
if (x == null || y == null)
{
return 0;
}
int num = x.Name.Length + x.Value.Length;
int num2 = y.Name.Length + y.Value.Length;
return num - num2;
}
}
}
}