MembershipUserCollection.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // System.Web.Security.MembershipUserCollection
  3. //
  4. // Authors:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2003 Ben Maurer
  8. //
  9. #if NET_1_2
  10. using System.Collections;
  11. using System.Web.UI;
  12. namespace System.Web.Security {
  13. public class MembershipUserCollection : ICloneable, ICollection {
  14. public MembershipUserCollection ()
  15. {
  16. }
  17. public void Add (MembershipUser user)
  18. {
  19. CheckNotReadOnly ();
  20. store.Add (user.Username, user);
  21. }
  22. public void Clear ()
  23. {
  24. CheckNotReadOnly ();
  25. store.Clear ();
  26. }
  27. public object Clone ()
  28. {
  29. MembershipUserCollection clone = new MembershipUserCollection ();
  30. foreach (MembershipUser u in this)
  31. clone.Add (u);
  32. return clone;
  33. }
  34. public void CopyTo (Array array, int index)
  35. {
  36. store.CopyTo (array, index);
  37. }
  38. public IEnumerator GetEnumerator ()
  39. {
  40. return ((IEnumerable) store).GetEnumerator ();
  41. }
  42. public void Remove (string name)
  43. {
  44. CheckNotReadOnly ();
  45. store.Remove (name);
  46. }
  47. public void SetReadOnly ()
  48. {
  49. readOnly = true;
  50. }
  51. public int Count {
  52. get { return store.Count; }
  53. }
  54. public bool IsSynchronized {
  55. get { return false; }
  56. }
  57. public MembershipUser this [string name] {
  58. get { return (MembershipUser) store [name]; }
  59. }
  60. public object SyncRoot {
  61. get { return this; }
  62. }
  63. void CheckNotReadOnly ()
  64. {
  65. if (readOnly)
  66. throw new InvalidOperationException ();
  67. }
  68. KeyedList store = new KeyedList ();
  69. bool readOnly = false;
  70. }
  71. }
  72. #endif