New test.
[mono.git] / mcs / class / System.Web / System.Web.Profile / ProfileInfoCollection.cs
1 //
2 // System.Web.Profile.ProfileInfoCollection.cs
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
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.
27 //
28
29 #if NET_2_0
30 using System;
31 using System.Collections;
32
33 namespace System.Web.Profile
34 {
35         [Serializable]
36         public sealed class ProfileInfoCollection : ICollection, IEnumerable
37         {
38                 public ProfileInfoCollection()
39                 {
40                         list = new ArrayList ();
41                 }
42
43                 public void Add (ProfileInfo profileInfo)
44                 {
45                         if (readOnly)
46                                 throw new NotSupportedException ();
47
48                         list.Add (profileInfo);
49                 }
50
51                 public void Clear ()
52                 {
53                         if (readOnly)
54                                 throw new NotSupportedException ();
55
56                         list.Clear ();
57                 }
58
59                 public void CopyTo (System.Array array, int index)
60                 {
61                         list.CopyTo (array, index);
62                 }
63
64                 public void CopyTo (ProfileInfo[ ] array, int index)
65                 {
66                         list.CopyTo (array, index);
67                 }
68
69                 public IEnumerator GetEnumerator ()
70                 {
71                         return list.GetEnumerator ();
72                 }
73
74                 public void Remove (string name)
75                 {
76                         if (readOnly)
77                                 throw new NotSupportedException ();
78
79                         for (int i = 0; i < list.Count; i ++) {
80                                 ProfileInfo info = (ProfileInfo)list[i];
81                                 if (info.UserName == name) {
82                                         list.Remove (i);
83                                         break;
84                                 }
85                         }
86                 }
87
88                 public void SetReadOnly ()
89                 {
90                         readOnly = true;
91                 }
92
93                 public int Count {
94                         get {
95                                 return list.Count;
96                         }
97                 }
98
99                 public bool IsSynchronized {
100                         get {
101                                 return false;
102                         }
103                 }
104
105                 public object SyncRoot {
106                         get {
107                                 return this;
108                         }
109                 }
110
111                 public ProfileInfo this [string name] {
112                         get {
113                                 for (int i = 0; i < list.Count; i ++) {
114                                         ProfileInfo info = (ProfileInfo)list[i];
115                                         if (info.UserName == name) {
116                                                 return info;
117                                         }
118                                 }
119
120                                 return null;
121                         }
122                 }
123
124                 ArrayList list;
125                 bool readOnly;
126         }
127
128 }
129 #endif