EventHandlerList.cs 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // System.ComponentModel.EventHandlerList.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // (C) Ximian, Inc. http://www.ximian.com
  8. //
  9. using System;
  10. using System.Collections;
  11. namespace System.ComponentModel {
  12. // <summary>
  13. // List of Event delegates.
  14. // </summary>
  15. //
  16. // <remarks>
  17. // Longer description
  18. // </remarks>
  19. public class EventHandlerList : IDisposable {
  20. Hashtable table;
  21. public EventHandlerList ()
  22. {
  23. }
  24. public Delegate this [object key] {
  25. get {
  26. if (table == null)
  27. return null;
  28. return (Delegate) table [key];
  29. }
  30. set {
  31. if (table == null)
  32. table = new Hashtable ();
  33. table.Add (key, value);
  34. }
  35. }
  36. public void AddHandler (object key, Delegate value)
  37. {
  38. if (table == null)
  39. table = new Hashtable ();
  40. table.Add (key, value);
  41. }
  42. public void RemoveHandler (object key, Delegate value)
  43. {
  44. table.Remove (key);
  45. }
  46. public void Dispose ()
  47. {
  48. table = null;
  49. }
  50. }
  51. }