Beispiel #1
0
        /// <summary>
        /// The method handler exector.
        /// </summary>
        /// <param name="action">The action to execute.</param>
        /// <param name="context">The transition context.</param>
        /// <returns>An async task.</returns>
        private async Task HandlerExecutor(StateMachineTransitionDel <TState, TTransition, TPayload> action, StateMachineTransitionContext <TState, TTransition, TPayload> context)
        {
            try
            {
                if (StateMachineLifetime.Error == context.CurrentLifecycle)
                {
                    return;
                }

                await action(context);
            }
            catch (Exception ex)
            {
                if (StateMachineLifetime.Error == context.CurrentLifecycle)
                {
                    return;
                }

                this.stateMachine.HandleFault(context, ex);
            }
        }
 /// <summary>
 /// Add a function to call on transition.
 /// </summary>
 /// <param name="func">The function to execute.</param>
 /// <returns>this.</returns>
 public IStateTransitionBuilder <TState, TTransition, TPayload> AddTransitionFunction(StateMachineTransitionDel <TState, TTransition, TPayload> func)
 {
     this.onTransitionFunctions.Add(func);
     return(this);
 }