2 // System.ServiceProcess.ServiceControllerPermissionEntry.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // (C) 2003, Ximian Inc.
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
31 using System.Collections;
32 using System.Security.Permissions;
34 namespace System.ServiceProcess {
37 public class ServiceControllerPermissionEntryCollection : CollectionBase {
39 private ServiceControllerPermission owner;
41 internal ServiceControllerPermissionEntryCollection (ServiceControllerPermission 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
57 public ServiceControllerPermissionEntry this [int index] {
58 get { return base.List [index] as ServiceControllerPermissionEntry; }
59 set { base.List [index] = value; }
62 public int Add (ServiceControllerPermissionEntry value)
64 return base.List.Add (value);
67 public void AddRange (ServiceControllerPermissionEntry [] value)
69 foreach (ServiceControllerPermissionEntry entry in value)
70 base.List.Add (entry);
73 public void AddRange (ServiceControllerPermissionEntryCollection value)
75 foreach (ServiceControllerPermissionEntry entry in value)
76 base.List.Add (entry);
79 public bool Contains (ServiceControllerPermissionEntry value)
81 return base.List.Contains (value);
84 public void CopyTo (ServiceControllerPermissionEntry [] array, int index)
86 base.List.CopyTo (array, index);
89 public int IndexOf (ServiceControllerPermissionEntry value)
91 return base.List.IndexOf (value);
94 public void Insert (int index, ServiceControllerPermissionEntry value)
96 base.List.Insert (index, value);
99 public void Remove (ServiceControllerPermissionEntry value)
101 base.List.Remove (value);
104 protected override void OnClear ()
106 owner.ClearEntries ();
109 protected override void OnInsert (int index, object value)
114 protected override void OnRemove (int index, object value)
116 owner.Remove (value);
119 protected override void OnSet (int index, object oldValue, object newValue)
121 owner.Remove (oldValue);
122 owner.Add (newValue);