protected void ExecuteAction(IStateMachineAction action, IStateTransition transition,
                                     StateTransitionPhase phase)
        {
            var context = new StateMachineActionContext
            {
                WorkflowContext   = this,
                Action            = action,
                CurrentTransition = transition,
                CurrentPhase      = phase
            };

            action.Execute(context);
        }
        public virtual object Execute(StateMachineActionContext context)
        {
            if (!ActionName.Contains("::"))
            {
                return(StateMachine.ActionTaskManager.ExecuteTask(ActionName, context));
            }

            //An alternate task execute syntax is being supported now that will
            //allow any method on a named task to be invoked using the ::, following the syntax
            //TaskName::MethodName

            string taskName   = ActionName.Substring(0, ActionName.IndexOf("::"));
            string methodName = ActionName.Substring(ActionName.IndexOf("::") + 2);

            ITask task = StateMachine.ActionTaskManager.CreateTask(taskName);

            if (task != null)
            {
                var wrapper = new CustomExecMethodTaskWrapper(task, methodName);
                return(wrapper.Execute(StateMachine.ActionTaskManager.CreateTaskContext(context)));
            }

            throw new ArgumentException("A task with the name " + taskName + " could not be found.");
        }
Exemplo n.º 3
0
 protected abstract object PerformStateMachineTask(StateMachineActionContext context);