Purpose: An entry task that has the ability to declare that a trigger should be set on the workflow allowing for an automatic redirection of state.  Subsequent Entry tasks will not be run on the current state when a trigger is set.

A mutating entry state task is functionality identical to a regular entry task with the exception that a “flow mutator” is handed to the execute method.  The mutator allows the task to set a trigger that will initiate a new state change according to the rules of that trigger on the current state.  Those rules are defined by the workflow configuration.


   1:  public interface IMutatingEntryStateTask<TState, TTrigger, TTriggerContext> : IStateTask<TState, TTrigger, TTriggerContext>
   2:  {
   3:      /// <summary>
   4:      /// Executes the specified entry state step info.
   5:      /// </summary>
   6:      /// <param name="entryStateTaskInfo">The entry state step info.</param>
   7:      /// <param name="flowMutator">The flow mutator.</param>
   8:      void Execute(EntryStateTaskInfo<TState, TTrigger, TTriggerContext> entryStateTaskInfo,
   9:                  IFlowMutator<TTrigger, TTriggerContext> flowMutator);
  10:  }

Changing the workflow is typically a task that involves interrogating the entryStateTaskInfo (and likely the Context property) to determine if the flowMutator should be set.

   1:  public class AutoApproveProcessor : IMutatingEntryStateTask<WorkflowState, StateTrigger, IDocumentContext>
   2:  {
   3:      public void Execute(EntryStateTaskInfo<WorkflowState, StateTrigger, IDocumentContext> entryStateTaskInfo, IFlowMutator<StateTrigger, IDocumentContext> flowMutator)
   4:      {
   5:          if(entryStateTaskInfo.Context.UserName == "foo")
   6:              flowMutator.SetTrigger(StateTrigger.Approve);
   7:      }
   8:  } 

When control returns to FluentWorkflow, any subsequent entry steps dependent on the AutoApproveProcessor will not be run and the trigger will be applied to the state machine. This will initiate the state exit steps on the current step and raise the entry states on the next state.

Last edited Jan 4, 2011 at 6:43 AM by sdhebert, version 4


No comments yet.