コード例 #1
0
ファイル: FlowHandler.cs プロジェクト: andybalham/FlowR
        private async Task <dynamic> GetActivityResponse(FlowContext stepFlowContext, FlowStep flowStep,
                                                         IFlowStepRequest activityRequest, CancellationToken cancellationToken)
        {
            var mockHandler =
                stepFlowContext.GetMockActivityHandler(
                    flowStep.Definition.RequestType, flowStep.Name);

            dynamic activityResponse;

            if (mockHandler == null)
            {
                var mediatorSendGeneric = _mediatorSend.MakeGenericMethod(flowStep.Definition.ResponseType);

                activityResponse =
                    await(dynamic) mediatorSendGeneric.Invoke(_mediator, new object[] { activityRequest, cancellationToken });
            }
            else
            {
                _logger?.LogMockRequestHandler(stepFlowContext, flowStep);

                activityResponse = mockHandler(activityRequest);
            }

            return(activityResponse);
        }
コード例 #2
0
ファイル: FlowHandler.cs プロジェクト: andybalham/FlowR
        private static void PopulateRequestBoundValues(IFlowStepRequest request, FlowObjectType requestType, FlowStep flowStep,
                                                       FlowValues flowValues, ISet <string> setPropertyNames)
        {
            var boundProperties = requestType.Properties.Where(p => !setPropertyNames.Contains(p.Name));

            foreach (var boundProperty in boundProperties)
            {
                var inputBinding = flowStep.Definition.GetInputBinding(boundProperty);

                if (inputBinding.TryGetRequestValue(flowValues, request, out var requestValue))
                {
                    boundProperty.PropertyInfo.SetValue(request, requestValue);
                }
            }
        }
コード例 #3
0
ファイル: FlowHandler.cs プロジェクト: andybalham/FlowR
        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);
        }