public IStateConfiguration <TEntity> Configure() { var cfg = new StateConfiguration <TEntity>(); Configurations.Add(cfg); return(cfg); }
private async Task OnStartTransition( StateTransitionContext <TEntity> context, StateMachine <string, string> .Transition transition, StateConfiguration <TEntity> configuration) { context.SourceState = transition.Source; context.TargetState = transition.Destination; context.Trigger = transition.Trigger; var handlers = configuration.Handlers .Select(t => _serviceProvider.GetService(t)) .Cast <IStateTransitionHandler <TEntity> >(); using var transaction = TransactionsFactory.Create(); foreach (var stateTransitionHandler in handlers) { await stateTransitionHandler.Transit(context); } transaction.Complete(); }