예제 #1
0
        /// <summary>
        /// Executes the method action by wrapping it with
        /// 1. Logging of start / end time.
        /// 2. Status updates.
        /// </summary>
        /// <param name="methodName">The name of the method being executed.</param>
        /// <param name="taskName">Option name to use for the TaskName for StatusUpdates.</param
        /// <param name="action">Action to execute.</param>
        public void Execute(string methodName, string taskName, ActionVoid action)
        {
            DateTime startTime = DateTime.Now;

            HandleStart(methodName, startTime);
            action();
            HandleEnd(methodName, startTime);
        }
예제 #2
0
        public Application()
        {
            startCallback = ProxyStart;
            exitCallback  = ProxyExit;

            _handle  = Application_new(startCallback, exitCallback);
            _current = this;
        }
예제 #3
0
        private void ExecuteAction(MouseButton button, ButtonState3 state)
        {
            ActionVoid action = _bindingMap.GetAction(button, state);

            if (action != null)
            {
                action.Execute();
            }
        }
예제 #4
0
        private void ExecuteAction(Keys key, ButtonState3 state)
        {
            ActionVoid action = _bindingMap.GetAction(key, state);

            if (action != null)
            {
                action.Execute();
            }
        }
예제 #5
0
        public static BComponent BuildComponent(XmlNode xmlDoc, BComponent parent, Behaviors behavior)
        {
            string name = xmlDoc.Name;

            if (ActionBool.NAME == name)
            {
                return(ActionBool.Build(xmlDoc, parent, behavior));
            }
            else if (ActionProperty.NAME == name)
            {
                return(ActionProperty.Build(xmlDoc, parent, behavior));
            }
            else if (ActionVoid.NAME == name)
            {
                return(ActionVoid.Build(xmlDoc, parent, behavior));
            }
            else if (ActionEnumerator.NAME == name)
            {
                return(ActionEnumerator.Build(xmlDoc, parent, behavior));
            }
            else if (RandomSelector.NAME == name)
            {
                return(RandomSelector.Build(xmlDoc, parent, behavior));
            }
            else if (RootSelector.NAME == name)
            {
                return(RootSelector.Build(xmlDoc, parent, behavior));
            }
            else if (Selector.NAME == name)
            {
                return(Selector.Build(xmlDoc, parent, behavior));
            }
            else if (Sequence.NAME == name)
            {
                return(Sequence.Build(xmlDoc, parent, behavior));
            }
            else if (Inverter.NAME == name)
            {
                return(Inverter.Build(xmlDoc, parent, behavior));
            }
            else if (UntilTrue.NAME == name)
            {
                return(UntilTrue.Build(xmlDoc, parent, behavior));
            }
            else if (UntilFalse.NAME == name)
            {
                return(UntilFalse.Build(xmlDoc, parent, behavior));
            }
            else
            {
                Debug.LogErrorFormat("I did not find the item: {0}", name);
                return(null);
            }
        }
예제 #6
0
 /// <summary>
 /// Executes an action inside a try catch and logs any exceptions.
 /// </summary>
 /// <param name="action"></param>
 public static void TryCatchLog(string errorMessage, ILog log, ActionVoid action)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         if (log != null)
         {
             log.Error(errorMessage, ex, null);
         }
     }
 }
예제 #7
0
 /// <summary>
 /// Executes an action inside a try catch and logs any exceptions.
 /// </summary>
 /// <param name="action"></param>
 public static void TryCatch(ActionVoid action, Action <Exception> exceptionHandler)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         if (exceptionHandler != null)
         {
             exceptionHandler(ex);
         }
     }
 }
예제 #8
0
 /// <summary>
 /// Executes the method action by wrapping it with
 /// 1. Logging of start / end time.
 /// 2. Status updates.
 /// </summary>
 /// <param name="methodName">The name of the method being executed.</param>
 /// <param name="taskName">Option name to use for the TaskName for StatusUpdates.</param>
 /// <param name="wrapTryCatch">Whether or not to wrap the call inside a try catch.</param>
 /// <param name="action">Action to execute.</param>
 public void Execute(string methodName, string taskName, bool wrapTryCatch, ActionVoid action)
 {
     Execute(methodName, taskName, () =>
     {
         if (!wrapTryCatch)
         {
             action();
         }
         else
         {
             ExecuteHelper.TryCatchLog(action);
         }
     });
 }
예제 #9
0
 /// <summary>
 /// Exectutes the action under a write operation after
 /// aquiring the writer lock.
 /// </summary>
 /// <param name="executor"></param>
 protected void ExecuteWrite(ActionVoid executor)
 {
     AcquireWriterLock();
     try
     {
         executor();
     }
     catch (Exception ex)
     {
     }
     finally
     {
         ReleaseWriterLock();
     }
 }
예제 #10
0
        public CustomActionList(Game game, GraphicSettings setting, CustomWorld world, Tracker tracker)
            : base(game, setting)
        {
            _world                   = world;
            _tracker                 = tracker;
            PlayerForward            = new ActionVoid(this.PlayerMoveForward);
            PlayerRight              = new ActionVoid(this.PlayerMoveRight);
            PlayerBackward           = new ActionVoid(this.PlayerMoveBackward);
            PlayerLeft               = new ActionVoid(this.PlayerMoveLeft);
            CameraRotation           = new ActionFloatFloat(this.RotateCamera);
            RotateCameraHorizontally = new ActionFloat(this.M_RotateCameraX);
            RotateCameraVertically   = new ActionFloat(this.M_RotateCameraY);
            Pause = new ActionVoid(this.M_Pause);

            Shoot = new ActionVoid(this.MethodShoot);
        }
예제 #11
0
 /// <summary>
 /// Exectutes the action under a write operation after
 /// aquiring the writer lock.
 /// </summary>
 /// <param name="executor"></param>
 protected static void ExecuteWrite(ActionVoid executor)
 {
     AcquireWriterLock();
     try
     {
         executor();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to execute write action in Logger." + ex.Message);
     }
     finally
     {
         ReleaseWriterLock();
     }
 }
예제 #12
0
 /// <summary>
 /// Executes an action inside a try catch and logs any exceptions.
 /// </summary>
 /// <param name="action"></param>
 public static void TryCatchFinallySafe(string errorMessage, ActionVoid action, Action <Exception> exceptionHandler, ActionVoid finallyHandler)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         if (exceptionHandler != null)
         {
             exceptionHandler(ex);
         }
     }
     finally
     {
         if (finallyHandler != null)
         {
             TryCatchHandle(() => finallyHandler());
         }
     }
 }
예제 #13
0
 public RRLine(ActionVoid voidfunc) : this()
 {
     _voidFuncs.Add(voidfunc);
 }
예제 #14
0
 public static extern IntPtr Application_new(ActionVoid start, ActionVoid exit);
예제 #15
0
 /// <summary>
 /// Executes an action inside a try catch and does not do anything when
 /// an exception occurrs.
 /// </summary>
 /// <param name="action"></param>
 public static void TryCatch(ActionVoid action)
 {
     TryCatchLog(string.Empty, null, action);
 }
예제 #16
0
        /// <summary>
        /// Executes an action inside a try catch and logs any exceptions.
        /// </summary>
        /// <param name="action"></param>
        public static void TryCatchLog(ActionVoid action)
        {
            ILog log = Logger.GetNew <ExecuteHelper>();

            TryCatchLog(string.Empty, log, action);
        }
예제 #17
0
 protected void BindButton(MouseButton button, ButtonState3 state, ActionVoid action)
 {
     buttonActionMap[state].Add(button, action);
 }
예제 #18
0
        /// <summary>
        /// Executes an action inside a try catch and logs any exceptions.
        /// </summary>
        /// <param name="action"></param>
        public static void TryCatchLog(string errorMessage, ActionVoid action)
        {
            ILog log = Logger.GetNew <ExecuteHelper>();

            TryCatchLog(errorMessage, log, action);
        }
예제 #19
0
 public RequestTread(ActionVoid action)
 {
     OnAction = action;
     RequestManager.AddRequest(this);
     Uri = "Action";
 }
예제 #20
0
 /// <summary>
 /// Executes an action inside a try catch and does not do anything when
 /// an exception occurrs.
 /// </summary>
 /// <param name="action"></param>
 public static void TryCatchHandle(ActionVoid actionCode, ActionVoid finallyCode)
 {
     TryCatchFinallySafe(string.Empty, actionCode, (ex) => HandleException(ex), finallyCode);
 }
예제 #21
0
 protected void Bind(Keys key, ButtonState3 state, ActionVoid action)
 {
     keyMap[state].Add(key, action);
 }
예제 #22
0
 //methods
 public void Add(ActionVoid av)
 {
     _voidFuncs.Add(av);
 }
예제 #23
0
 //constructors
 public ConLine(ActionVoid voidfunc, ConToken preset) : base(voidfunc)
 {
     _preset = preset;
 }