Almost eliminate wrong use of Constants.WsaNamespace.
[mono.git] / mcs / class / System.DirectoryServices / System.DirectoryServices / DirectoryServicesPermissionEntryCollection.cs
index 3cd35a674703a24741ddd10f5ee2a5a80888154c..95c07b65f6ef0df921bb0c45a76bd5c37f0e0753 100644 (file)
@@ -22,7 +22,7 @@
 *******************************************************************************/
 
 //
-// System.DirectoryServices.DirectoryEntry.cs
+// System.DirectoryServices.DirectoryServicesPermissionEntryCollection.cs
 //
 // Copyright (C) 2004  Novell Inc.
 //
 //
 
 using System.Collections;
-using System.Security;
 using System.Security.Permissions;
 
-namespace System.DirectoryServices
-{
-       public class DirectoryServicesPermissionEntryCollection : CollectionBase
-       {
-               internal DirectoryServicesPermissionEntryCollection () { }
+namespace System.DirectoryServices {
 
-               public DirectoryServicesPermissionEntry this[int index]
+       // when deserializing an instance serialized by MS.NET, you get the following 
+       // error : Field "owner" not found in class ....
+       [Serializable]
+       [MonoTODO ("Fix serialization compatibility with MS.NET")]
+       public class DirectoryServicesPermissionEntryCollection : CollectionBase {
+
+               private DirectoryServicesPermission owner;
+
+               internal DirectoryServicesPermissionEntryCollection (DirectoryServicesPermission owner)
                {
+                       this.owner = owner;
+                       ResourcePermissionBaseEntry[] entries = owner.GetEntries ();
+                       if (entries.Length > 0) {
+                               foreach (ResourcePermissionBaseEntry entry in entries) {
+                                       DirectoryServicesPermissionAccess dspa = (DirectoryServicesPermissionAccess) entry.PermissionAccess;
+                                       DirectoryServicesPermissionEntry dspe = new DirectoryServicesPermissionEntry (dspa, entry.PermissionAccessPath [0]);
+                                       // we don't want to add them (again) to the base class
+                                       InnerList.Add (dspe);
+                               }
+                       }
+               }
+
+               public DirectoryServicesPermissionEntry this [int index] {
                        get { return List[index] as DirectoryServicesPermissionEntry; }
                        set { List[index] = value; }
                }
@@ -88,24 +104,25 @@ namespace System.DirectoryServices
                        List.Remove (entry);
                }
 
-               [MonoTODO]
                protected override void OnClear ()
                {
+                       owner.ClearEntries ();
                }
 
-               [MonoTODO]
                protected override void OnInsert (int index, object value)
                {
+                       owner.Add (value);
                }
 
-               [MonoTODO]
                protected override void OnRemove (int index, object value)
                {
+                       owner.Remove (value);
                }
 
-               [MonoTODO]
                protected override void OnSet (int index, object oldValue, object newValue)
                {
+                       owner.Remove (oldValue);
+                       owner.Add (newValue);
                }
        }
 }