PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/WindowsBase/System.Windows/WeakEventManager.cs

https://bitbucket.org/danipen/mono
C# | 178 lines | 118 code | 33 blank | 27 comment | 5 complexity | f608a03ada7876c963ac6057228d2c55 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. //
  2. // WeakEventManager.cs
  3. //
  4. // Author:
  5. // Chris Toshok (toshok@ximian.com)
  6. //
  7. // (C) 2007 Novell, Inc.
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System.Collections;
  29. using System.Windows.Threading;
  30. namespace System.Windows {
  31. public abstract class WeakEventManager : DispatcherObject
  32. {
  33. Hashtable sourceData;
  34. protected WeakEventManager ()
  35. {
  36. sourceData = new Hashtable ();
  37. }
  38. protected IDisposable ReadLock {
  39. get { throw new NotImplementedException (); }
  40. }
  41. protected IDisposable WriteLock {
  42. get { throw new NotImplementedException (); }
  43. }
  44. protected object this [object source] {
  45. get { return sourceData[source]; }
  46. set { sourceData[source] = value; }
  47. }
  48. protected void DeliverEvent (object sender, EventArgs args)
  49. {
  50. DeliverEventToList (sender, args, (ListenerList)this[sender]);
  51. }
  52. protected void DeliverEventToList (object sender, EventArgs args, ListenerList list)
  53. {
  54. for (int i = 0; i < list.Count; i ++) {
  55. IWeakEventListener listener = list[i];
  56. listener.ReceiveWeakEvent (GetType(), sender, args);
  57. }
  58. }
  59. protected void ProtectedAddListener (object source, IWeakEventListener listener)
  60. {
  61. ListenerList list = sourceData[source] as ListenerList;
  62. if (list != null)
  63. list.Add (listener);
  64. }
  65. protected void ProtectedRemoveListener (object source, IWeakEventListener listener)
  66. {
  67. ListenerList list = sourceData[source] as ListenerList;
  68. if (list != null)
  69. list.Remove (listener);
  70. }
  71. protected virtual bool Purge (object source, object data, bool purgeAll)
  72. {
  73. throw new NotImplementedException ();
  74. }
  75. protected void Remove (object source)
  76. {
  77. throw new NotImplementedException ();
  78. }
  79. protected void ScheduleCleanup ()
  80. {
  81. throw new NotImplementedException ();
  82. }
  83. protected abstract void StartListening (object source);
  84. protected abstract void StopListening (object source);
  85. protected static WeakEventManager GetCurrentManager (Type managerType)
  86. {
  87. throw new NotImplementedException ();
  88. }
  89. protected static void SetCurrentManager (Type managerType, WeakEventManager manager)
  90. {
  91. throw new NotImplementedException ();
  92. }
  93. protected class ListenerList
  94. {
  95. public ListenerList ()
  96. {
  97. throw new NotImplementedException ();
  98. }
  99. public ListenerList (int capacity)
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. public int Count {
  104. get { throw new NotImplementedException (); }
  105. }
  106. public static ListenerList Empty {
  107. get { throw new NotImplementedException (); }
  108. }
  109. public bool IsEmpty {
  110. get { throw new NotImplementedException (); }
  111. }
  112. public IWeakEventListener this[int index] {
  113. get { throw new NotImplementedException (); }
  114. }
  115. public void Add (IWeakEventListener listener)
  116. {
  117. throw new NotImplementedException ();
  118. }
  119. public bool BeginUse ()
  120. {
  121. throw new NotImplementedException ();
  122. }
  123. public WeakEventManager.ListenerList Clone ()
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. public void EndUse ()
  128. {
  129. throw new NotImplementedException ();
  130. }
  131. public static bool PrepareForWriting (ref WeakEventManager.ListenerList list)
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. public bool Purge ()
  136. {
  137. throw new NotImplementedException ();
  138. }
  139. public void Remove (IWeakEventListener listener)
  140. {
  141. throw new NotImplementedException ();
  142. }
  143. }
  144. }
  145. }