PageRenderTime 1ms CodeModel.GetById 76ms app.highlight 7ms RepoModel.GetById 1ms 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
  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
 29using System.Collections;
 30using System.Windows.Threading;
 31
 32namespace System.Windows {
 33
 34	public abstract class WeakEventManager : DispatcherObject
 35	{
 36		Hashtable sourceData;
 37
 38		protected WeakEventManager ()
 39		{
 40			sourceData = new Hashtable ();
 41		}
 42
 43		protected IDisposable ReadLock {
 44			get { throw new NotImplementedException (); }
 45		}
 46
 47		protected IDisposable WriteLock {
 48			get { throw new NotImplementedException (); }
 49		}
 50
 51		protected object this [object source] {
 52			get { return sourceData[source]; }
 53			set { sourceData[source] = value; }
 54		}
 55
 56		protected void DeliverEvent (object sender, EventArgs args)
 57		{
 58			DeliverEventToList (sender, args, (ListenerList)this[sender]);
 59		}
 60
 61		protected void DeliverEventToList (object sender, EventArgs args, ListenerList list)
 62		{
 63			for (int i = 0; i < list.Count; i ++) {
 64				IWeakEventListener listener = list[i];
 65				listener.ReceiveWeakEvent (GetType(), sender, args);
 66			}
 67		}
 68
 69		protected void ProtectedAddListener (object source, IWeakEventListener listener)
 70		{
 71			ListenerList list = sourceData[source] as ListenerList;
 72			if (list != null)
 73				list.Add (listener);
 74		}
 75
 76		protected void ProtectedRemoveListener (object source, IWeakEventListener listener)
 77		{
 78			ListenerList list = sourceData[source] as ListenerList;
 79			if (list != null)
 80				list.Remove (listener);
 81		}
 82
 83		protected virtual bool Purge (object source, object data, bool purgeAll)
 84		{
 85			throw new NotImplementedException ();
 86		}
 87
 88		protected void Remove (object source)
 89		{
 90			throw new NotImplementedException ();
 91		}
 92
 93		protected void ScheduleCleanup ()
 94		{
 95			throw new NotImplementedException ();
 96		}
 97
 98		protected abstract void StartListening (object source);
 99		protected abstract void StopListening (object source);
100
101
102		protected static WeakEventManager GetCurrentManager (Type managerType)
103		{
104			throw new NotImplementedException ();
105		}
106
107		protected static void SetCurrentManager (Type managerType, WeakEventManager manager)
108		{
109			throw new NotImplementedException ();
110		}
111
112
113		protected class ListenerList
114		{
115			public ListenerList ()
116			{
117				throw new NotImplementedException ();
118			}
119
120			public ListenerList (int capacity)
121			{
122				throw new NotImplementedException ();
123			}
124
125			public int Count {
126				get { throw new NotImplementedException (); }
127			}
128
129			public static ListenerList Empty {
130				get { throw new NotImplementedException (); }
131			}
132
133			public bool IsEmpty {
134				get { throw new NotImplementedException (); }
135			}
136
137			public IWeakEventListener this[int index] {
138				get { throw new NotImplementedException (); }
139			}
140
141			public void Add (IWeakEventListener listener)
142			{
143				throw new NotImplementedException ();
144			}
145
146			public bool BeginUse ()
147			{
148				throw new NotImplementedException ();
149			}
150
151			public WeakEventManager.ListenerList Clone ()
152			{
153				throw new NotImplementedException ();
154			}
155
156			public void EndUse ()
157			{
158				throw new NotImplementedException ();
159			}
160
161			public static bool PrepareForWriting (ref WeakEventManager.ListenerList list)
162			{
163				throw new NotImplementedException ();
164			}
165
166			public bool Purge ()
167			{
168				throw new NotImplementedException ();
169			}
170
171			public void Remove (IWeakEventListener listener)
172			{
173				throw new NotImplementedException ();
174			}
175		}
176	}
177
178}