* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / RoleGroupCollection.cs
index c5da8e602cd4b5e413205de74ef061dde9bfed2e..722276444983f8e2fcf85f86c9a0e99c46dab5cb 100644 (file)
@@ -39,7 +39,7 @@ namespace System.Web.UI.WebControls {
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [Editor ("System.Web.UI.Design.WebControls.RoleGroupCollectionEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
-       public sealed class RoleGroupCollection : StateManagedCollection {
+       public sealed class RoleGroupCollection : CollectionBase {
 
                public RoleGroupCollection ()
                {
@@ -63,12 +63,15 @@ namespace System.Web.UI.WebControls {
 
                public void CopyTo (RoleGroup[] array, int index)
                {
-                       base.CopyTo (array, index);
-               }
-
-               protected override object CreateKnownType (int index)
-               {
-                       return new RoleGroup ();
+                       if (array == null)
+                               throw new ArgumentNullException ("array");
+                       if (index < 0)
+                               throw new ArgumentException (Locale.GetText ("Negative index."), "index");
+                       if (this.Count <= array.Length - index)
+                               throw new ArgumentException (Locale.GetText ("Destination isn't large enough to copy collection."), "array");
+
+                       for (int i=0; i < Count; i++)
+                               array [i + index] = this [i];
                }
 
                public RoleGroup GetMatchingRoleGroup (IPrincipal user)
@@ -97,18 +100,17 @@ namespace System.Web.UI.WebControls {
 
                public void Remove (RoleGroup group)
                {
-                       ((IList) this).Remove (group);
+                       // note: checks required or we'll throw more exceptions :(
+                       if (group != null) {
+                               if (Contains (group))
+                                       ((IList) this).Remove (group);
+                       }
                }
 
                [MonoTODO]
                public void OnValidate (object sender)
                {
                }
-
-               [MonoTODO]
-               protected override void SetDirtyObject (object o)
-               {
-               }
        }
 }