Exemplo n.º 1
0
 public static void Notify(RoadEvent e, object sender, EventArgs eArgs)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e", "No event type given!");
     }
     if (sender != null)
     {
         try
         {
             RoadEventHandlerCollection roadEventHandlerCollection = null;
             GameEventMgr.m_lock.AcquireReaderLock(3000);
             try
             {
                 roadEventHandlerCollection = (RoadEventHandlerCollection)GameEventMgr.m_GameObjectEventCollections[sender];
             }
             finally
             {
                 GameEventMgr.m_lock.ReleaseReaderLock();
             }
             if (roadEventHandlerCollection != null)
             {
                 roadEventHandlerCollection.Notify(e, sender, eArgs);
             }
         }
         catch (ApplicationException exception)
         {
             if (GameEventMgr.log.IsErrorEnabled)
             {
                 GameEventMgr.log.Error("Failed to notify local event handler!", exception);
             }
         }
     }
     GameEventMgr.m_GlobalHandlerCollection.Notify(e, sender, eArgs);
 }
Exemplo n.º 2
0
 public static void Notify(RoadEvent e, object sender, EventArgs eArgs)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e", "No event type given!");
     }
     if (sender != null)
     {
         try
         {
             RoadEventHandlerCollection col = null;
             GameEventMgr.m_lock.AcquireReaderLock(3000);
             try
             {
                 col = (RoadEventHandlerCollection)GameEventMgr.m_GameObjectEventCollections[sender];
             }
             finally
             {
                 GameEventMgr.m_lock.ReleaseReaderLock();
             }
             if (col != null)
             {
                 col.Notify(e, sender, eArgs);
             }
         }
         catch (ApplicationException ex)
         {
             LogProvider.Default.Error("Failed to notify local event handler!", ex);
         }
     }
     GameEventMgr.m_GlobalHandlerCollection.Notify(e, sender, eArgs);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Notifies all global and local event handlers of the occurance
        /// of a specific event type with some event arguments!
        /// </summary>
        /// <param name="e">The event type that occured</param>
        /// <param name="sender">The sender of this event</param>
        /// <param name="eArgs">The event arguments</param>
        /// <exception cref="ArgumentNullException">If no event type given</exception>
        /// <remarks>Overwrite the EventArgs class to set own arguments</remarks>
        public static void Notify(RoadEvent e, object sender, EventArgs eArgs)
        {
            //Test the parameters
            if (e == null)
            {
                throw new ArgumentNullException("e", "No event type given!");
            }

            //Notify the local event handlers first
            if (sender != null)
            {
                try
                {
                    RoadEventHandlerCollection col = null;
                    m_lock.AcquireReaderLock(TIMEOUT);
                    try
                    {
                        col = (RoadEventHandlerCollection)m_GameObjectEventCollections[sender];
                    }
                    finally
                    {
                        m_lock.ReleaseReaderLock();
                    }
                    if (col != null)
                    {
                        col.Notify(e, sender, eArgs);
                    }
                }
                catch (ApplicationException ex)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Failed to notify local event handler!", ex);
                    }
                }
            }
            //Notify the global ones later
            m_GlobalHandlerCollection.Notify(e, sender, eArgs);
        }