* OleDbParameterCollectionTest.cs: Fix compile error in 1.1 profile.
[mono.git] / mcs / class / System.ServiceProcess / System.ServiceProcess / ServiceControllerPermissionEntryCollection.cs
1 //
2 // System.ServiceProcess.ServiceControllerPermissionEntry.cs
3 //
4 // Authors:
5 //      Duncan Mak (duncan@ximian.com)
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // (C) 2003, Ximian Inc.
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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 using System.Security.Permissions;
33
34 namespace System.ServiceProcess {
35
36         [Serializable]
37         public class ServiceControllerPermissionEntryCollection : CollectionBase {
38
39                 private ServiceControllerPermission owner;
40
41                 internal ServiceControllerPermissionEntryCollection (ServiceControllerPermission owner)
42                 {
43                         this.owner = owner;
44                         ResourcePermissionBaseEntry[] entries = owner.GetEntries ();
45                         if (entries.Length > 0) {
46                                 foreach (ResourcePermissionBaseEntry entry in entries) {
47                                         ServiceControllerPermissionAccess scpa = (ServiceControllerPermissionAccess) entry.PermissionAccess;
48                                         string machine = entry.PermissionAccessPath [0];
49                                         string service = entry.PermissionAccessPath [1];
50                                         ServiceControllerPermissionEntry scpe = new ServiceControllerPermissionEntry (scpa, machine, service);
51                                         // we don't want to add them (again) to the base class
52                                         InnerList.Add (scpe);
53                                 }
54                         }
55                 }
56
57                 public ServiceControllerPermissionEntry this [int index] {
58                         get { return base.List [index] as ServiceControllerPermissionEntry; }
59                         set { base.List [index] = value; }
60                 }
61
62                 public int Add (ServiceControllerPermissionEntry value)
63                 {
64                         return base.List.Add (value);
65                 }
66
67                 public void AddRange (ServiceControllerPermissionEntry [] value)
68                 {
69                         foreach (ServiceControllerPermissionEntry entry in value)
70                                 base.List.Add (entry);
71                 }
72
73                 public void AddRange (ServiceControllerPermissionEntryCollection value)
74                 {
75                         foreach (ServiceControllerPermissionEntry entry in value)
76                                 base.List.Add (entry);
77                 }
78
79                 public bool Contains (ServiceControllerPermissionEntry value)
80                 {
81                         return base.List.Contains (value);
82                 }
83
84                 public void CopyTo (ServiceControllerPermissionEntry [] array, int index)
85                 {
86                         base.List.CopyTo (array, index);
87                 }
88
89                 public int IndexOf (ServiceControllerPermissionEntry value)
90                 {
91                         return base.List.IndexOf (value);
92                 }
93
94                 public void Insert (int index, ServiceControllerPermissionEntry value)
95                 {
96                         base.List.Insert (index, value);
97                 }
98
99                 public void Remove (ServiceControllerPermissionEntry value)
100                 {
101                         base.List.Remove (value);
102                 }
103
104                 protected override void OnClear ()
105                 {
106                         owner.ClearEntries ();
107                 }
108
109                 protected override void OnInsert (int index, object value)
110                 {
111                         owner.Add (value);
112                 }
113
114                 protected override void OnRemove (int index, object value)
115                 {
116                         owner.Remove (value);
117                 }
118
119                 protected override void OnSet (int index, object oldValue, object newValue)
120                 {
121                         owner.Remove (oldValue);
122                         owner.Add (newValue);
123                 }
124         }
125 }