Exemplo n.º 1
0
 /// <summary>
 /// Dispatches an event for a robot.
 /// </summary>
 /// <remarks>
 /// Too old events will not be dispatched and a critical event is always dispatched.
 /// </remarks>
 /// <param name="evnt">is the event to dispatch to the robot.</param>
 private void Dispatch(Event evnt)
 {
     if (robot != null && evnt != null)
     {
         try
         {
             // skip too old events
             if ((evnt.Time > Time - MAX_EVENT_STACK) || HiddenAccessN.IsCriticalEvent(evnt))
             {
                 HiddenAccessN.Dispatch(evnt, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl());
             }
         }
         catch (Exception ex)
         {
             if (ex is SecurityException)
             {
                 robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.Message);
             }
             else if (ex.InnerException is SecurityException)
             {
                 robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.InnerException + ": " + ex.Message);
             }
             else if (!(ex is EventInterruptedException || ex is AbortedException || ex is DeathException || ex is DisabledException || ex is WinException))
             {
                 robotProxy.println("SYSTEM: " + ex.GetType().Name + " occurred on " + evnt.GetType().Name);
                 robotProxy.GetOut().WriteLine(ex.StackTrace);
             }
             throw;
         }
     }
 }