public List <TriggerConfiguration> GetTriggerConfiguration() { var configurer = new TriggerConfigurer(); ConfigureTriggers(configurer); return(configurer.TriggerConfiguration); }
public static TriggerConfigurer FromMessage <TStateMachine, TMessage>( this TriggerConfigurer configurer, Func <TMessage, Guid> correlationFunc, Action <TStateMachine, TMessage> stateMachineAction, Action <IConsumerConfigurationBuilder> consumeConfig = null) { return(configurer.FromMessage <TStateMachine, TMessage>( correlationFunc, (machine, message) => { stateMachineAction(machine, message); return Task.FromResult(0); }, consumeConfig)); }
public static TriggerConfigurer FromMessage <TStateMachine, TMessage>( this TriggerConfigurer configurer, Func <TMessage, Guid> correlationFunc, Func <TStateMachine, TMessage, Task> machineFunc, Action <IConsumerConfigurationBuilder> consumeConfig = null ) { Func <object[], Task <Acknowledgement> > genericHandler = args => machineFunc((TStateMachine)args[0], (TMessage)args[1]).ContinueWith <Acknowledgement>(t => new Ack()); Func <object[], Guid> genericCorrFunc = args => correlationFunc((TMessage)args[0]); return(configurer.From(SubscribePipe, context => { var stateMachineContext = new StateMachineContext(context); stateMachineContext.Properties.Add(StateMachineKey.Type, typeof(TStateMachine)); stateMachineContext.Properties.Add(StateMachineKey.CorrelationFunc, genericCorrFunc); stateMachineContext.UseLazyCorrelationArgs(ctx => new[] { ctx.GetMessage() }); stateMachineContext.Properties.Add(PipeKey.MessageType, typeof(TMessage)); stateMachineContext.Properties.Add(PipeKey.ConfigurationAction, consumeConfig); stateMachineContext.Properties.Add(PipeKey.MessageHandler, genericHandler); stateMachineContext.UseLazyHandlerArgs(ctx => new[] { ctx.GetStateMachine(), ctx.GetMessage() }); })); }
public abstract void ConfigureTriggers(TriggerConfigurer trigger);