In .:
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / WizardStepCollection.cs
1 //
2 // System.Web.UI.WebControls.WizardStepCollection
3 //
4 // Authors:
5 //  Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.Collections;
35
36 namespace System.Web.UI.WebControls
37 {
38         public sealed class WizardStepCollection: IList
39         {
40                 ArrayList list = new ArrayList ();
41                 Wizard wizard;
42                 
43                 internal WizardStepCollection (Wizard wizard)
44                 {
45                         this.wizard = wizard;
46                 }
47                 
48                 public int Count {
49                         get { return list.Count; }
50                 } 
51                 
52                 public bool IsReadOnly {
53                         get { return false; }
54                 } 
55                 
56                 public bool IsSynchronized {
57                         get { return false; }
58                 }
59                 
60                 public WizardStepBase this [int index] {
61                         get { return (WizardStepBase) list [index]; }
62                 }
63                 
64                 public object SyncRoot {
65                         get { return this; }
66                 }
67                 
68                 public void Add (WizardStepBase wizardStep)
69                 {
70                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
71                         list.Add (wizardStep);
72                         wizard.UpdateViews ();
73                 }
74                 
75                 public void AddAt (int index, WizardStepBase wizardStep)
76                 {
77                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
78                         list.Insert (index, wizardStep);
79                         wizard.UpdateViews ();
80                 }
81                 
82                 public void Clear ()
83                 {
84                         list.Clear ();
85                         wizard.UpdateViews ();
86                 }
87                 
88                 public bool Contains (WizardStepBase wizardStep)
89                 {
90                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
91                         return list.Contains (wizardStep);
92                 }
93                 
94                 public void CopyTo (WizardStepBase[] array, int index)
95                 {
96                         list.CopyTo (array, index);
97                 }
98                 
99                 public IEnumerator GetEnumerator ()
100                 {
101                         return list.GetEnumerator ();
102                 }
103                 
104                 public int IndexOf (WizardStepBase wizardStep)
105                 {
106                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
107                         return list.IndexOf (wizardStep);
108                 }
109                 
110                 public void Insert (int index, WizardStepBase wizardStep)
111                 {
112                         AddAt (index, wizardStep);
113                 }
114                 
115                 public void Remove (WizardStepBase wizardStep)
116                 {
117                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
118                         list.Remove (wizardStep);
119                         wizard.UpdateViews ();
120                 }
121                 
122                 public void RemoveAt (int index)
123                 {
124                         list.RemoveAt (index);
125                         wizard.UpdateViews ();
126                 }
127                 
128                 bool IList.IsFixedSize {
129                         get { return false; }
130                 }
131                 
132                 object IList.this [int index] {
133                         get { return list [index]; }
134                         set { list [index] = value; }
135                 }
136                 
137                 int IList.Add (object ob)
138                 {
139                         int res = list.Add ((WizardStepBase)ob);
140                         wizard.UpdateViews ();
141                         return res;
142                 }
143                 
144                 bool IList.Contains (object ob)
145                 {
146                         return Contains ((WizardStepBase)ob);
147                 }
148                 
149                 int IList.IndexOf (object ob)
150                 {
151                         return IndexOf ((WizardStepBase)ob);
152                 }
153                 
154                 void IList.Insert (int index, object ob)
155                 {
156                         AddAt (index, (WizardStepBase)ob);
157                 }
158                 
159                 void IList.Remove (object ob)
160                 {
161                         Remove ((WizardStepBase)ob);
162                 }
163                 
164                 void ICollection.CopyTo (Array array, int index)
165                 {
166                         list.CopyTo (array, index);
167                 }
168         }
169 }
170
171 #endif