예제 #1
0
        private bool _canExecute(ScriptRunner runner, GadgetAction action, ScriptParameter param)
        {
            if (runner.CanExecuteScript != action.CanExecute)
            {
                var script = CSharpScript.Create <bool>(action.CanExecute, globalsType: typeof(ScriptParameter));
                runner.CanExecuteRunner = script.CreateDelegate();
                runner.CanExecuteScript = action.CanExecute;
            }

            var execution = runner.CanExecuteRunner(param);

            return(execution.Result);
        }
예제 #2
0
        private double _targetNewValue(ScriptRunner runner, GadgetAction action, ScriptParameter param)
        {
            if (runner.TargetNewValueScript != action.Execute)
            {
                var script = CSharpScript.Create <double>(action.Execute, globalsType: typeof(ScriptParameter));
                runner.TargetNewValueRunner = script.CreateDelegate();
                runner.TargetNewValueScript = action.Execute;
            }

            var execution = runner.TargetNewValueRunner(param);

            return(execution.Result);
        }
예제 #3
0
        public ScriptResult Execute(GadgetAction action, ScriptParameter param)
        {
            var returnValue = new ScriptResult();
            var runner      = _getRunner(action.Id);

            returnValue.CanExecute = _canExecute(runner, action, param);

            if (returnValue.CanExecute)
            {
                returnValue.TargetNewValue = _targetNewValue(runner, action, param);
            }
            return(returnValue);
        }