In .:
[mono.git] / mcs / class / System.Configuration.Install / System.Configuration.Install / InstallerCollection.cs
1 // InstallerCollection.cs
2 //   System.Configuration.Install.InstallerCollection class implementation
3 //
4 // Author:
5 //    Muthu Kannan (t.manki@gmail.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 using System.Collections;
32
33 namespace System.Configuration.Install
34 {
35
36 public class InstallerCollection : CollectionBase {
37         private Installer parent;
38
39         // Constructors
40         internal InstallerCollection (Installer parent)
41         {
42                 this.parent = parent;
43         }
44
45         // Properties
46         public Installer this [int index] {
47                 get {
48                         return (Installer)List [index];
49                 }
50                 set {
51                         List [index] = value;
52                 }
53         }
54
55         // Methods
56         public int Add (Installer installer)
57         {
58                 return List.Add (installer);
59         }
60
61         public void AddRange (Installer [] installers)
62         {
63                 foreach (Installer ins in installers)
64                         Add (ins);
65         }
66
67         public void AddRange (InstallerCollection installers)
68         {
69                 foreach (Installer ins in installers)
70                         Add (ins);
71         }
72
73         public bool Contains (Installer installer)
74         {
75                 return List.Contains (installer);
76         }
77
78         public void CopyTo (Installer [] array, int index)
79         {
80                 List.CopyTo (array, index);
81         }
82
83         public int IndexOf (Installer installer)
84         {
85                 return List.IndexOf (installer);
86         }
87
88         public void Insert (int index, Installer installer)
89         {
90                 List.Insert (index, installer);
91         }
92
93         public void Remove (Installer installer)
94         {
95                 List.Remove (installer);
96         }
97
98         protected override void OnInsert (int index, object val)
99         {
100                 ((Installer)val).Parent = parent;
101         }
102
103         protected override void OnRemove (int index, object val)
104         {
105                 ((Installer)val).Parent = null;
106         }
107
108         protected override void OnSet (int index, object oldVal, object newVal)
109         {
110                 ((Installer)oldVal).Parent = null;
111                 ((Installer)newVal).Parent = parent;
112         }
113 }
114
115 }