2
0

DataBindingCollection.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // System.Web.UI.DataBindingCollection.cs
  3. //
  4. // Duncan Mak ([email protected])
  5. //
  6. // (C) Ximian, Inc.
  7. //
  8. using System;
  9. using System.Collections;
  10. namespace System.Web.UI {
  11. public sealed class DataBindingCollection : ICollection, IEnumerable
  12. {
  13. Hashtable list;
  14. ArrayList removed;
  15. public DataBindingCollection ()
  16. {
  17. list = new Hashtable ();
  18. removed = new ArrayList ();
  19. }
  20. public int Count {
  21. get { return list.Count; }
  22. }
  23. public bool IsReadOnly {
  24. get { return list.IsReadOnly; }
  25. }
  26. public bool IsSynchronized {
  27. get { return list.IsSynchronized; }
  28. }
  29. public DataBinding this [string propertyName] {
  30. get { return list [propertyName] as DataBinding; }
  31. }
  32. public string [] RemovedBindings {
  33. get { return (string []) removed.ToArray (typeof (string)); }
  34. }
  35. public object SyncRoot {
  36. get { return list.SyncRoot; }
  37. }
  38. public void Add (DataBinding binding)
  39. {
  40. list.Add (binding.PropertyName, binding);
  41. }
  42. public void Clear ()
  43. {
  44. list.Clear ();
  45. }
  46. public void CopyTo (Array array, int index)
  47. {
  48. list.CopyTo (array, index);
  49. }
  50. public IEnumerator GetEnumerator ()
  51. {
  52. return list.GetEnumerator ();
  53. }
  54. public void Remove (DataBinding binding)
  55. {
  56. string key = binding.PropertyName;
  57. Remove (key);
  58. }
  59. public void Remove (string propertyName)
  60. {
  61. removed.Add (propertyName);
  62. list.Remove (propertyName);
  63. }
  64. public void Remove (string propertyName,
  65. bool addToRemovedList)
  66. {
  67. if (addToRemovedList)
  68. removed.Add (String.Empty); // LAMESPEC
  69. else
  70. removed.Add (propertyName);
  71. list.Remove (propertyName);
  72. }
  73. }
  74. }