blob: b26645f78e27b1d27d5b9f949f7e6ae227919b15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
//
// System.Net.CookieCollection
//
// Author:
// Lawrence Pit (loz@cable.a2000.nl)
//
using System;
using System.Collections;
using System.Runtime.Serialization;
namespace System.Net
{
[Serializable]
public class CookieCollection : ICollection, IEnumerable
{
private ArrayList list = new ArrayList ();
// ctor
public CookieCollection ()
{
}
// ICollection
public int Count {
get { return list.Count; }
}
public bool IsSynchronized {
get { return false; }
}
public Object SyncRoot {
get { return this; }
}
public void CopyTo (Array array, int arrayIndex)
{
list.CopyTo (array, arrayIndex);
}
// IEnumerable
public IEnumerator GetEnumerator ()
{
return list.GetEnumerator ();
}
// This
// LAMESPEC: So how is one supposed to create a writable CookieCollection
// instance?? We simply ignore this property, as this collection is always
// writable.
public bool IsReadOnly {
get { return true; }
}
// LAMESPEC: Which exception should we throw when the read only
// property is set to true??
public void Add (Cookie cookie)
{
if (cookie == null)
throw new ArgumentNullException ("cookie");
int pos = list.IndexOf (cookie);
if (pos == -1)
list.Add (cookie);
else
list [pos] = cookie;
}
// LAMESPEC: Which exception should we throw when the read only
// property is set to true??
public void Add (CookieCollection cookies)
{
if (cookies == null)
throw new ArgumentNullException ("cookies");
IEnumerator enumerator = cookies.list.GetEnumerator ();
while (enumerator.MoveNext ())
Add ((Cookie) enumerator.Current);
}
public Cookie this [int index] {
get {
if (index < 0 || index >= list.Count)
throw new ArgumentOutOfRangeException ("index");
return (Cookie) list [index];
}
}
public Cookie this [string name] {
get {
lock (this) {
IEnumerator enumerator = list.GetEnumerator ();
while (enumerator.MoveNext ())
if (String.Compare (((Cookie) enumerator.Current).Name, name, true) == 0)
return (Cookie) enumerator.Current;
}
return null;
}
}
} // CookieCollection
} // System.Net
|