(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System / System.Net / CookieCollection.cs
blob3170e47bdbe083dcfa0371c1403077d3195997de
1 //
2 // System.Net.CookieCollection
3 //
4 // Author:
5 // Lawrence Pit (loz@cable.a2000.nl)
6 //
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Collections;
31 using System.Runtime.Serialization;
33 namespace System.Net
35 [Serializable]
36 public class CookieCollection : ICollection, IEnumerable
38 private ArrayList list = new ArrayList ();
40 // ctor
41 public CookieCollection ()
45 // ICollection
47 public int Count {
48 get { return list.Count; }
51 public bool IsSynchronized {
52 get { return false; }
55 public Object SyncRoot {
56 get { return this; }
59 public void CopyTo (Array array, int arrayIndex)
61 list.CopyTo (array, arrayIndex);
65 // IEnumerable
67 public IEnumerator GetEnumerator ()
69 return list.GetEnumerator ();
73 // This
75 // LAMESPEC: So how is one supposed to create a writable CookieCollection
76 // instance?? We simply ignore this property, as this collection is always
77 // writable.
78 public bool IsReadOnly {
79 get { return true; }
82 // LAMESPEC: Which exception should we throw when the read only
83 // property is set to true??
84 public void Add (Cookie cookie)
86 if (cookie == null)
87 throw new ArgumentNullException ("cookie");
88 int pos = list.IndexOf (cookie);
89 if (pos == -1)
90 list.Add (cookie);
91 else
92 list [pos] = cookie;
95 // LAMESPEC: Which exception should we throw when the read only
96 // property is set to true??
97 public void Add (CookieCollection cookies)
99 if (cookies == null)
100 throw new ArgumentNullException ("cookies");
102 IEnumerator enumerator = cookies.list.GetEnumerator ();
103 while (enumerator.MoveNext ())
104 Add ((Cookie) enumerator.Current);
107 public Cookie this [int index] {
108 get {
109 if (index < 0 || index >= list.Count)
110 throw new ArgumentOutOfRangeException ("index");
111 return (Cookie) list [index];
115 public Cookie this [string name] {
116 get {
117 lock (this) {
118 IEnumerator enumerator = list.GetEnumerator ();
119 while (enumerator.MoveNext ())
120 if (String.Compare (((Cookie) enumerator.Current).Name, name, true) == 0)
121 return (Cookie) enumerator.Current;
123 return null;
128 } // CookieCollection
130 } // System.Net