Example #1
0
        /// <summary>
        /// 在调用此命令时要调用的方法。
        /// 备注:请在此方法的最后一定加上 OnExecuted
        /// </summary>
        /// <param name="parameter"></param>
        public virtual async void Execute(object parameter)
        {
            var cancellationToken = Cancel.Initialization();

            IsCompleted = false;
            IsFaulted   = false;
            Exception   = null;
            // 备注:此方法会触发所有 ICommand.CanExecute
            CommandManager.InvalidateRequerySuggested();
            try
            {
                await ExecuteDelegate.Invoke(parameter, cancellationToken);

                IsCancel = cancellationToken.IsCancellationRequested;
            }
            catch (OperationCanceledException)
            {
                IsCancel = true;
            }
            catch (Exception ex)
            {
                IsFaulted = true;
                Exception = ex;
            }
            IsCompleted = true;
            CommandManager.InvalidateRequerySuggested();
            OnExecuted();
        }
Example #2
0
 public void Execute()
 {
     if (OnExecute != null)
     {
         OnExecute.Invoke();
     }
 }
Example #3
0
 public void Execute(object parameter)
 {
     if (CanExecute(parameter ?? value))
     {
         ExecuteDelegate?.Invoke(parameter ?? value);
     }
 }
Example #4
0
 public ItemTrigggerEffectBefore(CheckConditionDelegate onCheckCondition, ExecuteDelegate onExecute)
     : base(PileName.ITEM, onCheckCondition, null, async(g, c, a) =>
 {
     await onExecute?.Invoke(g, c, a);
     await c.damage(g, c, 1);
     await g.updateDeath();
 })
 {
 }
Example #5
0
 public ItemTrigggerEffectAfter(CheckConditionDelegate onCheckCondition, ExecuteDelegate onExecute)
     : base(PileName.ITEM, onCheckCondition, null, async(g, c, a) =>
 {
     await onExecute?.Invoke(g, c, a);
     c.setCurrentLife(c.getCurrentLife(g) - 1);
     await g.updateDeath();
 })
 {
 }
Example #6
0
 public void Execute(string commandName)
 {
     if (this.CommandList.ContainsKey(commandName))
     {
         ExecuteDelegate execMethod = this.CommandList[commandName].ExecuteMethod;
         if (execMethod != null)
         {
             execMethod.Invoke();
         }
     }
 }
Example #7
0
 public void Execute(object parameter)
 {
     if (ParameterizedExecuteDelegate != null)
     {
         ParameterizedExecuteDelegate(parameter);
     }
     else
     {
         ExecuteDelegate?.Invoke();
     }
 }
Example #8
0
 protected T ExecuteQuery <T>(ExecuteDelegate <T> del)
 {
     try
     {
         var mongoCollection = this.dataBase.GetCollection <Y>(this.collection);
         return(del.Invoke(mongoCollection));
     }
     catch (Exception ex)
     {
         throw this.ProcessException(ex);
     }
 }
Example #9
0
 public BeforeYourTurnEnd(ExecuteDelegate onExecute) : base(PileName.FIELD, (game, card, arg) =>
 {
     return(arg.player == card.getOwner());
 }, null, async(game, card, arg) =>
 {
     if (onExecute != null)
     {
         await onExecute.Invoke(game, card, arg);
         await game.updateDeath();
     }
 })
 {
 }
Example #10
0
        public void Execute(object parameter)
        {
            var window = parameter as Window;

            if (window != null)
            {
                window.Effect = new BlurEffect {
                    Radius = 4
                };
            }

            ExecuteDelegate?.Invoke(parameter);

            if (window != null)
            {
                window.Effect = null;
                window.Close();
            }
        }
Example #11
0
 public THHEffectAfter(string pile, CheckConditionDelegate onCheckCondition, CheckTargetDelegate onCheckTarget, ExecuteDelegate onExecute) :
     base(new After <T>(), pile, (game, card, vars) =>
 {
     if (onCheckCondition != null && vars != null && vars.Length > 0 && vars[0] is T t)
     {
         return(onCheckCondition.Invoke(game, card, t));
     }
     else
     {
         return(true);
     }
 }, onCheckTarget, (game, card, vars, targets) =>
 {
     if (onExecute != null && vars != null && vars.Length > 0 && vars[0] is T t)
     {
         return(onExecute.Invoke(game, card, t));
     }
     else
     {
         return(Task.CompletedTask);
     }
 })
 {
 }
Example #12
0
 public void Execute(object parameter)
 {
     _Execute.Invoke(parameter);
 }
Example #13
0
 public void Execute(object parameter) => ExecuteDelegate?.Invoke(parameter);
Example #14
0
 public void ExecuteStage()
 {
     execute.Invoke();
 }
 public void Execute(object parameter)
 {
     _execMethod?.Invoke(parameter);
 }
Example #16
0
 public void Execute(object parameter)
 {
     ExecuteDelegate?.Invoke(parameter, null);
 }
Example #17
0
 /// <summary>
 /// Executes the actual command
 /// </summary>
 /// <param name="parameter">THe command parameter to be passed</param>
 public void Execute(object parameter)
 {
     ExecuteDelegate?.Invoke(parameter);
     ExecuteDelegateWithoutObject?.Invoke();
 }
Example #18
0
 /// <summary>
 /// 执行操作核心
 /// </summary>
 protected override void ExecuteCore()
 {
     ExecuteDelegate?.Invoke();
 }