Merge pull request #1179 from ludovic-henry/pr25-threadpool
[mono.git] / mcs / class / System.Web / System.Web.Security / MembershipUserCollection.cs
index f754de1f98029e4791fb2de464f831d951dfa751..61d486345c393eb1cff95544ffecae1845b458e9 100644 (file)
@@ -5,8 +5,7 @@
 //     Ben Maurer (bmaurer@users.sourceforge.net)
 //
 // (C) 2003 Ben Maurer
-//
-
+// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 using System.Collections;
+using System.Runtime.CompilerServices;
 using System.Web.UI;
 
-namespace System.Web.Security {
-       public class MembershipUserCollection : ICloneable, ICollection {
+namespace System.Web.Security
+{
+#if NET_4_0
+       [TypeForwardedFrom ("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+#endif
+       [Serializable]
+       public sealed class MembershipUserCollection : ICollection
+       {
                public MembershipUserCollection ()
                {
                }
                
                public void Add (MembershipUser user)
                {
+                       if (user == null)
+                               throw new ArgumentNullException ("user");
+
                        CheckNotReadOnly ();
-                       store.Add (user.Username, user);
+                       store.Add (user.UserName, user);
                }
                
                public void Clear ()
@@ -50,17 +58,14 @@ namespace System.Web.Security {
                        store.Clear ();
                }
                
-               public object Clone ()
+               void ICollection.CopyTo (Array array, int index)
                {
-                       MembershipUserCollection clone = new MembershipUserCollection ();
-                       foreach (MembershipUser u in this)
-                               clone.Add (u);
-                       return clone;
+                       store.Values.CopyTo (array, index);
                }
                
-               public void CopyTo (Array array, int index)
+               public void CopyTo (MembershipUser[] array, int index)
                {
-                       store.CopyTo (array, index);
+                       store.Values.CopyTo (array, index);
                }
                
                public IEnumerator GetEnumerator ()
@@ -98,12 +103,12 @@ namespace System.Web.Security {
                void CheckNotReadOnly ()
                {
                        if (readOnly)
-                               throw new InvalidOperationException ();
+                               throw new NotSupportedException ();
                }
                
                KeyedList store = new KeyedList ();
                bool readOnly = false;
        }
 }
-#endif
+