Example #1
0
 public static TriggerConfigurer FromMessage <TStateMachine, TMessage, TMessageContext>(
     this TriggerConfigurer configurer,
     Func <TMessage, TMessageContext, Guid> correlationFunc,
     Action <TStateMachine, TMessage, TMessageContext> stateMachineAction,
     Action <IConsumerConfigurationBuilder> consumeConfig = null)
 {
     return(configurer.FromMessage <TStateMachine, TMessage, TMessageContext>(
                correlationFunc, (machine, message, context) =>
     {
         stateMachineAction(machine, message, context);
         return Task.FromResult(0);
     },
                consumeConfig));
 }
 public override void ConfigureTriggers(TriggerConfigurer trigger)
 {
     trigger
     .FromMessage <GenericProcess, CreateTask>(
         process => Guid.NewGuid(),
         (task, msg) => task.CreateAsync(msg.Name, msg.DeadLine))
     .FromMessage <GenericProcess, StartTask>(
         start => start.TaskId,
         (task, msg) => task.StartAsync(msg.Assignee))
     .FromMessage <GenericProcess, PauseTask>(
         pause => pause.TaskId,
         (task, pause) => task.PauseAsync(pause.Reason))
     .FromMessage <GenericProcess, ResumeTask>(
         pause => pause.TaskId,
         (task, msg) => task.ResumeAsync())
     .FromMessage <GenericProcess, CompleteTask>(
         complete => complete.TaskId,
         (task, complete) => task.CompleteAsync())
     .FromMessage <GenericProcess, AbortTask>(
         abort => abort.TaskId,
         (task, abort) => task.Abort(abort.Reason)
         );
 }