2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / class / WindowsBase / System.Windows / WeakEventManager.cs
blobff5c29c449cd501470d23ec30e661853951c3bc7
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.
29 using System.Collections;
30 using System.Windows.Threading;
32 namespace System.Windows {
34 public abstract class WeakEventManager : DispatcherObject
36 Hashtable sourceData;
38 protected WeakEventManager ()
40 sourceData = new Hashtable ();
43 protected IDisposable ReadLock {
44 get { throw new NotImplementedException (); }
47 protected IDisposable WriteLock {
48 get { throw new NotImplementedException (); }
51 protected object this [object source] {
52 get { return sourceData[source]; }
53 set { sourceData[source] = value; }
56 protected void DeliverEvent (object sender, EventArgs args)
58 DeliverEventToList (sender, args, (ListenerList)this[sender]);
61 protected void DeliverEventToList (object sender, EventArgs args, ListenerList list)
63 for (int i = 0; i < list.Count; i ++) {
64 IWeakEventListener listener = list[i];
65 listener.ReceiveWeakEvent (GetType(), sender, args);
69 protected void ProtectedAddListener (object source, IWeakEventListener listener)
71 ListenerList list = sourceData[source] as ListenerList;
72 if (list != null)
73 list.Add (listener);
76 protected void ProtectedRemoveListener (object source, IWeakEventListener listener)
78 ListenerList list = sourceData[source] as ListenerList;
79 if (list != null)
80 list.Remove (listener);
83 protected virtual bool Purge (object source, object data, bool purgeAll)
85 throw new NotImplementedException ();
88 protected void Remove (object source)
90 throw new NotImplementedException ();
93 protected void ScheduleCleanup ()
95 throw new NotImplementedException ();
98 protected abstract void StartListening (object source);
99 protected abstract void StopListening (object source);
102 protected static WeakEventManager GetCurrentManager (Type managerType)
104 throw new NotImplementedException ();
107 protected static void SetCurrentManager (Type managerType, WeakEventManager manager)
109 throw new NotImplementedException ();
113 protected class ListenerList
115 public ListenerList ()
117 throw new NotImplementedException ();
120 public ListenerList (int capacity)
122 throw new NotImplementedException ();
125 public int Count {
126 get { throw new NotImplementedException (); }
129 public static ListenerList Empty {
130 get { throw new NotImplementedException (); }
133 public bool IsEmpty {
134 get { throw new NotImplementedException (); }
137 public IWeakEventListener this[int index] {
138 get { throw new NotImplementedException (); }
141 public void Add (IWeakEventListener listener)
143 throw new NotImplementedException ();
146 public bool BeginUse ()
148 throw new NotImplementedException ();
151 public WeakEventManager.ListenerList Clone ()
153 throw new NotImplementedException ();
156 public void EndUse ()
158 throw new NotImplementedException ();
161 public static bool PrepareForWriting (ref WeakEventManager.ListenerList list)
163 throw new NotImplementedException ();
166 public bool Purge ()
168 throw new NotImplementedException ();
171 public void Remove (IWeakEventListener listener)
173 throw new NotImplementedException ();