public DefaultStateMachineFiller( IStateMachineExecutor <TState, TStateId> executor, TStateId stateIdToFill) { Executor = executor; StateIdToFill = stateIdToFill; }
public StateMachineSafeExecutor( IStateMachineExecutor <TState> realExecutor, Action <Exception>?handler) { _realExecutor = realExecutor.ThrowIfNull(nameof(realExecutor)); _handler = handler ?? (ex => Logger.Exception(ex)); }
private static IStateMachineExecutor <State, StateId> FillExecutor( this IStateMachineExecutor <State, StateId> executor) { return(executor .On(StateId.StateA).GoTo(new TaskA()) .On(StateId.StateB).GoTo(new TaskB()) .On(StateId.StateC).GoTo(new TaskC()) .On(StateId.FinalState).GoTo(FinalStatefulTask <State> .Create(StateId.FinalState))); }
public static TState Execute <TState, TStateId>( this IStateMachineExecutor <TState, TStateId> executor) where TState : class { executor.ThrowIfNull(nameof(executor)); using (var enumerator = executor.GetEnumerator()) { while (enumerator.MoveNext()) { // All actions perform in MoveNext. } } return(executor.State); }
public StateMachine(IStateMachineDefinition <TState, TTrigger> definition, IStateMachineExecutor <TState, TTrigger, TContext> executor = null) { Definition = definition; Executor = executor ?? new StateMachineExecutor <TState, TTrigger, TContext>(); }
public static IStateMachineExecutor <TState, TStateId> CatchExceptions <TState, TStateId>( this IStateMachineExecutor <TState, TStateId> executor) where TState : class { return(executor.CatchExceptions(handler: null)); }
public static IStateMachineExecutor <TState, TStateId> CatchExceptions <TState, TStateId>( this IStateMachineExecutor <TState, TStateId> executor, Action <Exception>?handler) where TState : class { return(new StateMachineSafeExecutor <TState, TStateId>(executor, handler)); }
public static IStateMachineFiller <TState, TStateId> On <TState, TStateId>( this IStateMachineExecutor <TState, TStateId> executor, TStateId stateId) where TState : class { return(DefaultStateMachineFiller.Create(executor, stateId)); }