public StateMachineWithRollbackProvider( IStateMachineProvider <TContext, TStateId, TStatefulTaskWithRollback> realProvider, bool continueRollbackOnFailed) { _realProvider = realProvider.ThrowIfNull(nameof(realProvider)); _continueRollbackOnFailed = continueRollbackOnFailed; }
public static IStateMachineProvider <TContext, TStateId, TStatefulTask> CatchExceptions <TContext, TStateId, TStatefulTask>( this IStateMachineProvider <TContext, TStateId, TStatefulTask> provider, Action <Exception>?handler) where TStatefulTask : class, IStatefulTask <TContext, TStateId> { return(provider.CatchExceptions(continueExecutionOnFailed: false, handler)); }
public Engine(IWorkItemRepository repository, IActivityRunner activityRunner, IStateMachineProvider stateMachineProvider) { if (repository == null) throw new ArgumentNullException("repository"); if (activityRunner == null) throw new ArgumentNullException("activityRunner"); if (stateMachineProvider == null) throw new ArgumentNullException("stateMachineProvider"); _repository = repository; _activityRunner = activityRunner; _stateMachineProvider = stateMachineProvider; _stateQueue = new ActionBlock<int>(id => UpdateState(id), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 }); _workerQueue = new ActionBlock<int>(id => RunActivity(id), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = int.MaxValue }); _stateQueue.Completion.ContinueWith(t => { _workerQueue.Complete(); }, TaskContinuationOptions.OnlyOnFaulted); _workerQueue.Completion.ContinueWith(t => { ((IDataflowBlock) _stateQueue).Fault(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted); }
public static IStateMachineProvider <TContext, TStateId, TStatefulTask> CatchExceptions <TContext, TStateId, TStatefulTask>( this IStateMachineProvider <TContext, TStateId, TStatefulTask> provider, bool continueExecutionOnFailed) where TStatefulTask : class, IStatefulTask <TContext, TStateId> { return(provider.CatchExceptions(continueExecutionOnFailed, handler: null)); }
public StateMachineSafeProvider( IStateMachineProvider <TContext, TStateId, TStatefulTask> realProvider, bool continueExecutionOnFailed, Action <Exception>?handler) { _realProvider = realProvider.ThrowIfNull(nameof(realProvider)); _continueExecutionOnFailed = continueExecutionOnFailed; _handler = handler ?? (ex => Logger.Exception(ex)); }
public static IStateMachineProvider <TContext, TStateId, IStatefulTaskWithRollback <TContext, TStateId> > WithRollbackOnException <TContext, TStateId, TStatefulTaskWithRollback>( this IStateMachineProvider <TContext, TStateId, TStatefulTaskWithRollback> provider, bool continueRollbackOnFailed) where TStatefulTaskWithRollback : class, IStatefulTaskWithRollback <TContext, TStateId> { return(new StateMachineWithRollbackProvider <TContext, TStateId, TStatefulTaskWithRollback>( provider, continueRollbackOnFailed )); }
public static IStateMachineProvider <TContext, TStateId, TStatefulTask> CatchExceptions <TContext, TStateId, TStatefulTask>( this IStateMachineProvider <TContext, TStateId, TStatefulTask> provider, bool continueExecutionOnFailed, Action <Exception>?handler) where TStatefulTask : class, IStatefulTask <TContext, TStateId> { return(new StateMachineSafeProvider <TContext, TStateId, TStatefulTask>( provider, continueExecutionOnFailed, handler )); }
public MainViewModel(IStateMachineProvider stateMachineProvider, IMessageBroker messageBroker, IDialogs dialogs) { this.dialogs = dialogs; stateMachine = stateMachineProvider.GetStateMachine(); messageBroker.OnSend += AppendMessage; InitializeStates(); InitializeCommands(); UpdateCurrentState(); SetStateMachineInfo(); }
public static TContext Execute <TContext, TStateId, TStatefulTask>( this IStateMachineProvider <TContext, TStateId, TStatefulTask> provider) where TStatefulTask : class, IStatefulTask <TContext, TStateId> { provider.ThrowIfNull(nameof(provider)); using var enumerator = provider.GetStateMachineEnumerator(); while (enumerator.MoveNext()) { // All actions perform in MoveNext. } return(enumerator.Context); }
public BarStateflowProvider(IRepository <Bar> repository, IStateMachineProvider stateMachineProvider) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (stateMachineProvider == null) { throw new ArgumentNullException(nameof(stateMachineProvider)); } _repository = repository; _stateMachineProvider = stateMachineProvider; }
public static Task <IStateMachine <EFooState, EFooAction> > GetStateMachineAsync( this IStateMachineProvider provider, Foo entity, CancellationToken cancellationToken ) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(provider.GetStateMachineAsync <Foo, EFooState, EFooAction>( entity, x => x.State, (x, state) => x.ChangeState(state), cancellationToken )); }
public EngineTests() { _activityRunner = Substitute.For<IActivityRunner>(); _stateMachineProvider = Substitute.For<IStateMachineProvider>(); _engine = new Engine(_repository, _activityRunner, _stateMachineProvider); }
public static IStateMachineProvider <TContext, TStateId, IStatefulTaskWithRollback <TContext, TStateId> > WithRollbackOnException <TContext, TStateId, TStatefulTaskWithRollback>( this IStateMachineProvider <TContext, TStateId, TStatefulTaskWithRollback> provider) where TStatefulTaskWithRollback : class, IStatefulTaskWithRollback <TContext, TStateId> { return(provider.WithRollbackOnException(continueRollbackOnFailed: true)); }