Exemple #1
0
        private async Task <int> PerformFlowStep(FlowContext stepFlowContext, FlowDefinition <TFlowRequest, TFlowResponse> flowDefinition, FlowStep flowStep,
                                                 int flowStepIndex, FlowValues flowValues, FlowTrace flowTrace, CancellationToken cancellationToken)
        {
            int nextFlowStepIndex;

            switch (flowStep)
            {
            case ActivityFlowStep activityFlowStep:
                await DoActivity(
                    activityFlowStep, stepFlowContext, flowValues,
                    flowTrace, cancellationToken);

                nextFlowStepIndex = flowStepIndex + 1;
                break;

            case DecisionFlowStepBase decisionFlowStep:
                nextFlowStepIndex =
                    CheckDecision(
                        flowStepIndex, decisionFlowStep, flowDefinition, stepFlowContext, flowValues,
                        flowTrace);
                break;

            case GotoFlowStep gotoFlowStep:
                _logger.LogGoto(stepFlowContext, gotoFlowStep.NextStepName);
                nextFlowStepIndex = flowDefinition.GetStepIndex(gotoFlowStep.NextStepName);
                break;

            case LabelFlowStep _:
                RecordLabelStep(flowTrace, stepFlowContext);
                nextFlowStepIndex = flowStepIndex + 1;
                break;

            case EndFlowStep _:
                nextFlowStepIndex = int.MaxValue;
                break;

            default:
                throw new FlowException(
                          $"Unexpected flow activityFlowStep type {flowStep.GetType().FullName}");
            }

            return(nextFlowStepIndex);
        }