CacheDependency.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // System.Web.Caching
  3. //
  4. // Author:
  5. // Patrik Torstensson ([email protected])
  6. //
  7. // (C) Copyright Patrik Torstensson, 2001
  8. //
  9. namespace System.Web.Caching
  10. {
  11. /// <summary>
  12. /// Class to handle cache dependency, right now this class is only a mookup
  13. /// </summary>
  14. public class CacheDependency : System.IDisposable
  15. {
  16. private bool _boolDisposed;
  17. public CacheDependency()
  18. {
  19. _boolDisposed = false;
  20. }
  21. public delegate void CacheDependencyCallback(CacheDependency objDependency);
  22. public event CacheDependencyCallback Changed;
  23. public void OnChanged()
  24. {
  25. if (_boolDisposed)
  26. {
  27. throw new System.ObjectDisposedException("System.Web.CacheDependency");
  28. }
  29. if (Changed != null)
  30. {
  31. Changed(this);
  32. }
  33. }
  34. public bool IsDisposed
  35. {
  36. get
  37. {
  38. return _boolDisposed;
  39. }
  40. }
  41. public bool HasEvents
  42. {
  43. get
  44. {
  45. if (_boolDisposed)
  46. {
  47. throw new System.ObjectDisposedException("System.Web.CacheDependency");
  48. }
  49. if (Changed != null)
  50. {
  51. return true;
  52. }
  53. return false;
  54. }
  55. }
  56. public void Dispose()
  57. {
  58. _boolDisposed = true;
  59. }
  60. /// <summary>
  61. /// Used in testing.
  62. /// </summary>
  63. public void Signal()
  64. {
  65. OnChanged();
  66. }
  67. }
  68. }