Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public GadgetAction BindGadgetActionData(SqliteDataReader reader)
        {
            GadgetAction returnValue = new GadgetAction
            {
                Id           = reader.GetValueAsGuid("Id"),
                Order        = (int)(long)reader.GetValue(reader.GetOrdinal("Order")),
                TargetGadget = reader.GetValueAsGuid("TargetGadget"),
                SourceGadget = reader.GetValueAsGuid("SourceGadget"),
                CanExecute   = reader.GetValue(reader.GetOrdinal("CanExecute")).ToString(),
                Execute      = reader.GetValue(reader.GetOrdinal("Execute")).ToString(),
            };

            return(returnValue);
        }