Ejemplo n.º 1
0
        /// <summary>
        /// Removes all global event handlers for a specific event type
        /// </summary>
        /// <param name="e">The event type from which to deregister all handlers</param>
        /// <param name="deep">Specifies if all local registered event handlers
        /// should be removed as well.</param>
        /// <exception cref="ArgumentNullException">If no event type given</exception>
        public static void RemoveAllHandlers(RoadEvent e, bool deep)
        {
            //Test the parameters
            if (e == null)
            {
                throw new ArgumentNullException("e", "No event type given!");
            }

            if (deep)
            {
                try
                {
                    m_lock.AcquireReaderLock(TIMEOUT);
                    try
                    {
                        foreach (RoadEventHandlerCollection col in m_GameObjectEventCollections.Values)
                        {
                            col.RemoveAllHandlers(e);
                        }
                    }
                    finally
                    {
                        m_lock.ReleaseReaderLock();
                    }
                }
                catch (ApplicationException ex)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Failed to add local event handlers!", ex);
                    }
                }
            }
            m_GlobalHandlerCollection.RemoveAllHandlers(e);
        }
Ejemplo n.º 2
0
 public static void RemoveAllHandlers(object obj, RoadEvent e)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj", "No object given!");
     }
     if (e == null)
     {
         throw new ArgumentNullException("e", "No event type given!");
     }
     try
     {
         GameEventMgr.m_lock.AcquireReaderLock(3000);
         try
         {
             RoadEventHandlerCollection col = (RoadEventHandlerCollection)GameEventMgr.m_GameObjectEventCollections[obj];
             if (col != null)
             {
                 col.RemoveAllHandlers(e);
             }
         }
         finally
         {
             GameEventMgr.m_lock.ReleaseReaderLock();
         }
     }
     catch (ApplicationException ex)
     {
         LogProvider.Default.Error("Failed to remove local event handlers!", ex);
     }
 }
Ejemplo n.º 3
0
 public static void RemoveAllHandlers(object obj, RoadEvent e)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj", "No object given!");
     }
     if (e == null)
     {
         throw new ArgumentNullException("e", "No event type given!");
     }
     try
     {
         GameEventMgr.m_lock.AcquireReaderLock(3000);
         try
         {
             RoadEventHandlerCollection roadEventHandlerCollection = (RoadEventHandlerCollection)GameEventMgr.m_GameObjectEventCollections[obj];
             if (roadEventHandlerCollection != null)
             {
                 roadEventHandlerCollection.RemoveAllHandlers(e);
             }
         }
         finally
         {
             GameEventMgr.m_lock.ReleaseReaderLock();
         }
     }
     catch (ApplicationException exception)
     {
         if (GameEventMgr.log.IsErrorEnabled)
         {
             GameEventMgr.log.Error("Failed to remove local event handlers!", exception);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes all event handlers of a specific type
        /// from a specific object
        /// </summary>
        /// <param name="obj">The object from which to remove the handlers</param>
        /// <param name="e">The event type from which to deregister all handlers</param>
        /// <exception cref="ArgumentNullException">If no event type given</exception>
        public static void RemoveAllHandlers(object obj, RoadEvent e)
        {
            //Test the parameters
            if (obj == null)
            {
                throw new ArgumentNullException("obj", "No object given!");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e", "No event type given!");
            }

            try
            {
                m_lock.AcquireReaderLock(TIMEOUT);
                try
                {
                    RoadEventHandlerCollection col = (RoadEventHandlerCollection)m_GameObjectEventCollections[obj];
                    if (col != null)
                    {
                        col.RemoveAllHandlers(e);
                    }
                }
                finally
                {
                    m_lock.ReleaseReaderLock();
                }
            }
            catch (ApplicationException ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Failed to remove local event handlers!", ex);
                }
            }
        }