/// <summary>
		/// Post the notification to this notification center.
		/// </summary>
		/// <remarks>
		/// Instead of calling this method directly, it is usually easier to use one of the
		/// convenience <c>PostNotifcation</c> methods, which create the notification
		/// internally.
		/// </remarks>
		/// <param name="aNotification">The notification to post.</param>
		public virtual void PostNotification(PNotification aNotification) {
			ArrayList mergedListeners = new ArrayList();
			IList listenersList;
		
			Object name = aNotification.Name;
			Object obj = aNotification.Object;

			if (name != null) {
				if (obj != null) { // both are specified
					listenersList = (IList) listenersMap[new CompoundKey(name, obj)];
					if (listenersList != null) {
						mergedListeners.AddRange(listenersList);
					}
					listenersList = (IList) listenersMap[new CompoundKey(name, NULL_MARKER)];
					if (listenersList != null) {
						mergedListeners.AddRange(listenersList);
					}
					listenersList = (IList) listenersMap[new CompoundKey(NULL_MARKER, obj)];
					if (listenersList != null) {
						mergedListeners.AddRange(listenersList);
					}
				} else { // object is null
					listenersList = (IList) listenersMap[new CompoundKey(name, NULL_MARKER)];
					if (listenersList != null) {
						mergedListeners.AddRange(listenersList);
					}
				}
			} else if (obj != null) { // name is null
				listenersList = (IList) listenersMap[new CompoundKey(NULL_MARKER, obj)];
				if (listenersList != null) {
					mergedListeners.AddRange(listenersList);
				}
			}

			Object key = new CompoundKey(NULL_MARKER, NULL_MARKER);
			listenersList = (IList) listenersMap[key];
			if (listenersList != null) {
				mergedListeners.AddRange(listenersList);
			}

			CompoundValue val;
			TEMP_LIST.Clear();
			TEMP_LIST.AddRange(mergedListeners);
			IEnumerator i = TEMP_LIST.GetEnumerator();

			while (i.MoveNext()) {
				val = (CompoundValue) i.Current;
				if (val.Target == null) {
					mergedListeners.Remove(val);
				} else {
					try {
						val.MethodInfo.Invoke(val.Target, new Object[] { aNotification });
					} catch (MethodAccessException e) {
						System.Console.WriteLine(e.StackTrace);
					} catch (TargetInvocationException e) {
						System.Console.WriteLine(e.StackTrace);
					}
				}
			}
		}
示例#2
0
        /// <summary>
        /// Post the notification to this notification center.
        /// </summary>
        /// <remarks>
        /// Instead of calling this method directly, it is usually easier to use one of the
        /// convenience <c>PostNotifcation</c> methods, which create the notification
        /// internally.
        /// </remarks>
        /// <param name="aNotification">The notification to post.</param>
        public virtual void PostNotification(PNotification aNotification)
        {
            ArrayList mergedListeners = new ArrayList();
            IList     listenersList;

            Object name = aNotification.Name;
            Object obj  = aNotification.Object;

            if (name != null)
            {
                if (obj != null)                   // both are specified
                {
                    listenersList = (IList)listenersMap[new CompoundKey(name, obj)];
                    if (listenersList != null)
                    {
                        mergedListeners.AddRange(listenersList);
                    }
                    listenersList = (IList)listenersMap[new CompoundKey(name, NULL_MARKER)];
                    if (listenersList != null)
                    {
                        mergedListeners.AddRange(listenersList);
                    }
                    listenersList = (IList)listenersMap[new CompoundKey(NULL_MARKER, obj)];
                    if (listenersList != null)
                    {
                        mergedListeners.AddRange(listenersList);
                    }
                }
                else                     // object is null
                {
                    listenersList = (IList)listenersMap[new CompoundKey(name, NULL_MARKER)];
                    if (listenersList != null)
                    {
                        mergedListeners.AddRange(listenersList);
                    }
                }
            }
            else if (obj != null)                 // name is null
            {
                listenersList = (IList)listenersMap[new CompoundKey(NULL_MARKER, obj)];
                if (listenersList != null)
                {
                    mergedListeners.AddRange(listenersList);
                }
            }

            Object key = new CompoundKey(NULL_MARKER, NULL_MARKER);

            listenersList = (IList)listenersMap[key];
            if (listenersList != null)
            {
                mergedListeners.AddRange(listenersList);
            }

            CompoundValue val;

            TEMP_LIST.Clear();
            TEMP_LIST.AddRange(mergedListeners);
            IEnumerator i = TEMP_LIST.GetEnumerator();

            while (i.MoveNext())
            {
                val = (CompoundValue)i.Current;
                if (val.Target == null)
                {
                    mergedListeners.Remove(val);
                }
                else
                {
                    try {
                        val.MethodInfo.Invoke(val.Target, new Object[] { aNotification });
                    } catch (MethodAccessException e) {
                        System.Console.WriteLine(e.StackTrace);
                    } catch (TargetInvocationException e) {
                        System.Console.WriteLine(e.StackTrace);
                    }
                }
            }
        }
		public void selectionChanged(PNotification notfication) {
			System.Console.WriteLine("selection changed");
		}