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 32 using System; 33 using System.Collections; 34 35 namespace System.Web.UI.WebControls 36 { 37 public sealed class WizardStepCollection : IList, ICollection, IEnumerable 38 { 39 ArrayList list = new ArrayList (); 40 Wizard wizard; 41 WizardStepCollection(Wizard wizard)42 internal WizardStepCollection (Wizard wizard) 43 { 44 this.wizard = wizard; 45 } 46 47 public int Count { 48 get { return list.Count; } 49 } 50 51 public bool IsReadOnly { 52 get { return false; } 53 } 54 55 public bool IsSynchronized { 56 get { return false; } 57 } 58 59 public WizardStepBase this [int index] { 60 get { return (WizardStepBase) list [index]; } 61 } 62 63 public object SyncRoot { 64 get { return this; } 65 } 66 Add(WizardStepBase wizardStep)67 public void Add (WizardStepBase wizardStep) 68 { 69 if (wizardStep == null) throw new ArgumentNullException ("wizardStep"); 70 wizardStep.SetWizard (wizard); 71 list.Add (wizardStep); 72 wizard.UpdateViews (); 73 } 74 AddAt(int index, WizardStepBase wizardStep)75 public void AddAt (int index, WizardStepBase wizardStep) 76 { 77 if (wizardStep == null) throw new ArgumentNullException ("wizardStep"); 78 wizardStep.SetWizard (wizard); 79 list.Insert (index, wizardStep); 80 wizard.UpdateViews (); 81 } 82 Clear()83 public void Clear () 84 { 85 list.Clear (); 86 wizard.UpdateViews (); 87 } 88 Contains(WizardStepBase wizardStep)89 public bool Contains (WizardStepBase wizardStep) 90 { 91 if (wizardStep == null) throw new ArgumentNullException ("wizardStep"); 92 return list.Contains (wizardStep); 93 } 94 CopyTo(WizardStepBase[] array, int index)95 public void CopyTo (WizardStepBase[] array, int index) 96 { 97 list.CopyTo (array, index); 98 } 99 GetEnumerator()100 public IEnumerator GetEnumerator () 101 { 102 return list.GetEnumerator (); 103 } 104 IndexOf(WizardStepBase wizardStep)105 public int IndexOf (WizardStepBase wizardStep) 106 { 107 if (wizardStep == null) throw new ArgumentNullException ("wizardStep"); 108 return list.IndexOf (wizardStep); 109 } 110 Insert(int index, WizardStepBase wizardStep)111 public void Insert (int index, WizardStepBase wizardStep) 112 { 113 AddAt (index, wizardStep); 114 } 115 Remove(WizardStepBase wizardStep)116 public void Remove (WizardStepBase wizardStep) 117 { 118 if (wizardStep == null) throw new ArgumentNullException ("wizardStep"); 119 list.Remove (wizardStep); 120 wizard.UpdateViews (); 121 } 122 RemoveAt(int index)123 public void RemoveAt (int index) 124 { 125 list.RemoveAt (index); 126 wizard.UpdateViews (); 127 } 128 129 bool IList.IsFixedSize { 130 get { return false; } 131 } 132 133 object IList.this [int index] { 134 get { return list [index]; } 135 set { list [index] = value; } 136 } 137 IList.Add(object ob)138 int IList.Add (object ob) 139 { 140 int res = list.Add ((WizardStepBase)ob); 141 wizard.UpdateViews (); 142 return res; 143 } 144 IList.Contains(object ob)145 bool IList.Contains (object ob) 146 { 147 return Contains ((WizardStepBase)ob); 148 } 149 IList.IndexOf(object ob)150 int IList.IndexOf (object ob) 151 { 152 return IndexOf ((WizardStepBase)ob); 153 } 154 IList.Insert(int index, object ob)155 void IList.Insert (int index, object ob) 156 { 157 AddAt (index, (WizardStepBase)ob); 158 } 159 IList.Remove(object ob)160 void IList.Remove (object ob) 161 { 162 Remove ((WizardStepBase)ob); 163 } 164 ICollection.CopyTo(Array array, int index)165 void ICollection.CopyTo (Array array, int index) 166 { 167 list.CopyTo (array, index); 168 } 169 } 170 } 171 172