Exemple #1
0
        public override bool CanExecute(IParameterDic pm)
        {
            IParameterDic pm2 = pm.Clone();

            ScriptRunner.RunScriptAsync(pm2, ConditionCommand);
            return(pm2.IsHandled() && pm2.Error() == null);
        }
        public static void RunScript(IParameterDic initialParameters, bool cloneParameters, params IScriptCommand[] commands)
        {
            if (cloneParameters)
            {
                initialParameters = initialParameters.Clone();
            }

            IScriptRunner runner = initialParameters.Get <IScriptRunner>("{ScriptRunner}", Instance);

            runner.Run(new Queue <IScriptCommand>(commands), initialParameters);
        }
        public static Task RunScriptAsync(IParameterDic initialParameters, bool cloneParameters, params IScriptCommand[] commands)
        {
            if (cloneParameters)
            {
                initialParameters = initialParameters.Clone();
            }

            IScriptRunner runner = initialParameters.Get <IScriptRunner>("{ScriptRunner}", Instance);

            return(runner.RunAsync(new Queue <IScriptCommand>(commands), initialParameters));
        }
Exemple #4
0
        public override async Task <IScriptCommand> ExecuteAsync(IParameterDic pm)
        {
            switch (Mode)
            {
            case RunMode.Parallel:
                await Task.WhenAll(ScriptCommands.Select(cmd => ScriptRunner.RunScriptAsync(pm.Clone(), cmd)));

                break;

            case RunMode.Queue:
                await ScriptRunner.RunScriptAsync(pm, ScriptCommands)
                .ConfigureAwait(this.ContinueOnCaptureContext);

                break;

            case RunMode.Sequence:
                foreach (var cmd in ScriptCommands)
                {
                    await ScriptRunner.RunScriptAsync(pm, cmd)
                    .ConfigureAwait(this.ContinueOnCaptureContext);

                    if (pm.Error() != null)
                    {
                        return(ResultCommand.Error(pm.Error()));
                    }
                }
                break;

            default:
                return(ResultCommand.Error(new NotSupportedException(Mode.ToString())));
            }

            if (pm.Error() != null)
            {
                return(ResultCommand.Error(pm.Error()));
            }
            else
            {
                return(NextCommand);
            }
        }