コード例 #1
0
        public IStateConfiguration <TEntity> Configure()
        {
            var cfg = new StateConfiguration <TEntity>();

            Configurations.Add(cfg);
            return(cfg);
        }
コード例 #2
0
ファイル: StateManager.cs プロジェクト: KyMback/sht
        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();
        }