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

248 lines
9.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
namespace System.Net
{
/// <summary>Provides a collection container for instances of the <see cref="T:System.Net.Cookie" /> class.</summary>
// 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<Cookie> List
{
get
{
return this.list;
}
}
/// <summary>Gets the number of cookies contained in a <see cref="T:System.Net.CookieCollection" />.</summary>
/// <returns>The number of cookies contained in a <see cref="T:System.Net.CookieCollection" />.</returns>
// Token: 0x170005C9 RID: 1481
// (get) Token: 0x0600119D RID: 4509 RVA: 0x00033CDC File Offset: 0x00031EDC
public int Count
{
get
{
return this.list.Count;
}
}
/// <summary>Gets a value that indicates whether access to a <see cref="T:System.Net.CookieCollection" /> is thread safe.</summary>
/// <returns>true if access to the <see cref="T:System.Net.CookieCollection" /> is thread safe; otherwise, false. The default is false.</returns>
// Token: 0x170005CA RID: 1482
// (get) Token: 0x0600119E RID: 4510 RVA: 0x00033CEC File Offset: 0x00031EEC
public bool IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets an object that you can use to synchronize access to the <see cref="T:System.Net.CookieCollection" />.</summary>
/// <returns>An object that you can use to synchronize access to the <see cref="T:System.Net.CookieCollection" />.</returns>
// Token: 0x170005CB RID: 1483
// (get) Token: 0x0600119F RID: 4511 RVA: 0x00033CF0 File Offset: 0x00031EF0
public object SyncRoot
{
get
{
return this;
}
}
/// <summary>Copies the elements of a <see cref="T:System.Net.CookieCollection" /> to an instance of the <see cref="T:System.Array" /> class, starting at a particular index.</summary>
/// <param name="array">The target <see cref="T:System.Array" /> to which the <see cref="T:System.Net.CookieCollection" /> will be copied. </param>
/// <param name="index">The zero-based index in the target <see cref="T:System.Array" /> where 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 this <see cref="T:System.Net.CookieCollection" /> 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 elements in this <see cref="T:System.Net.CookieCollection" /> cannot be cast automatically to the type of the destination <paramref name="array" />. </exception>
// Token: 0x060011A0 RID: 4512 RVA: 0x00033CF4 File Offset: 0x00031EF4
public void CopyTo(Array array, int index)
{
((ICollection)this.list).CopyTo(array, index);
}
/// <summary>Copies the elements of this <see cref="T:System.Net.CookieCollection" /> to a <see cref="T:System.Net.Cookie" /> array starting at the specified index of the target array.</summary>
/// <param name="array">The target <see cref="T:System.Net.Cookie" /> array to which the <see cref="T:System.Net.CookieCollection" /> will be copied.</param>
/// <param name="index">The zero-based index in the target <see cref="T:System.Array" /> where 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 this <see cref="T:System.Net.CookieCollection" /> 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 elements in this <see cref="T:System.Net.CookieCollection" /> cannot be cast automatically to the type of the destination <paramref name="array" />. </exception>
// Token: 0x060011A1 RID: 4513 RVA: 0x00033D04 File Offset: 0x00031F04
public void CopyTo(Cookie[] array, int index)
{
this.list.CopyTo(array, index);
}
/// <summary>Gets an enumerator that can iterate through a <see cref="T:System.Net.CookieCollection" />.</summary>
/// <returns>An instance of an implementation of an <see cref="T:System.Collections.IEnumerator" /> interface that can iterate through a <see cref="T:System.Net.CookieCollection" />.</returns>
// Token: 0x060011A2 RID: 4514 RVA: 0x00033D14 File Offset: 0x00031F14
public IEnumerator GetEnumerator()
{
return this.list.GetEnumerator();
}
/// <summary>Gets a value that indicates whether a <see cref="T:System.Net.CookieCollection" /> is read-only.</summary>
/// <returns>true if this is a read-only <see cref="T:System.Net.CookieCollection" />; otherwise, false. The default is true.</returns>
// Token: 0x170005CC RID: 1484
// (get) Token: 0x060011A3 RID: 4515 RVA: 0x00033D28 File Offset: 0x00031F28
public bool IsReadOnly
{
get
{
return true;
}
}
/// <summary>Adds a <see cref="T:System.Net.Cookie" /> to a <see cref="T:System.Net.CookieCollection" />.</summary>
/// <param name="cookie">The <see cref="T:System.Net.Cookie" /> to be added to a <see cref="T:System.Net.CookieCollection" />. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="cookie" /> is null. </exception>
// 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;
}
/// <summary>Adds the contents of a <see cref="T:System.Net.CookieCollection" /> to the current instance.</summary>
/// <param name="cookies">The <see cref="T:System.Net.CookieCollection" /> to be added. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="cookies" /> is null. </exception>
// 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);
}
}
/// <summary>Gets the <see cref="T:System.Net.Cookie" /> with a specific index from a <see cref="T:System.Net.CookieCollection" />.</summary>
/// <returns>A <see cref="T:System.Net.Cookie" /> with a specific index from a <see cref="T:System.Net.CookieCollection" />.</returns>
/// <param name="index">The zero-based index of the <see cref="T:System.Net.Cookie" /> to be found. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than 0 or <paramref name="index" /> is greater than or equal to <see cref="P:System.Net.CookieCollection.Count" />. </exception>
// 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];
}
}
/// <summary>Gets the <see cref="T:System.Net.Cookie" /> with a specific name from a <see cref="T:System.Net.CookieCollection" />.</summary>
/// <returns>The <see cref="T:System.Net.Cookie" /> with a specific name from a <see cref="T:System.Net.CookieCollection" />.</returns>
/// <param name="name">The name of the <see cref="T:System.Net.Cookie" /> to be found. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null. </exception>
// 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<Cookie> list = new List<Cookie>();
// Token: 0x04000F8B RID: 3979
private static CookieCollection.CookieCollectionComparer Comparer = new CookieCollection.CookieCollectionComparer();
// Token: 0x02000207 RID: 519
private sealed class CookieCollectionComparer : IComparer<Cookie>
{
// 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;
}
}
}
}