static bool getResultFromPrevIfElse( SagaSteps childSteps, ISagaStep step, SagaExecutionState sagaState) { while (true) { ISagaStep prevStepIf = GetPrevStepSameLevel(childSteps, step.ParentStep, step); if (prevStepIf.Is <ISagaStepForIf>()) { IStepData stepDataIf = sagaState.History. GetLatestByStepName(prevStepIf.StepName); if (stepDataIf?.ExecutionData?.ConditionResult == true) { return(true); } if (!prevStepIf.Is <ISagaStepForElse>()) { return(false); } step = prevStepIf; } else { return(false); } } }
static NextStepInfo getNextStepForIf( ISagaAction sagaAction, ISagaStep step, SagaExecutionState sagaState) { if (step.Is <ISagaStepForIf>()) { IStepData currentStepData = sagaState.History. GetLatestByStepName(step.StepName); if (currentStepData?.ExecutionData?.ConditionResult == true) { return(new NextStepInfo { NextStep = step.ChildSteps.GetFirstStep() }); } else { return(new NextStepInfo { NextStep = GetNextStepElsewhere(sagaAction.ChildSteps, step) }); } } return(null); }
static ISagaStep getNextStepForElse( ISagaAction sagaAction, ISagaStep step, SagaExecutionState sagaState) { if (step.Is <ISagaStepForElse>()) { bool ifElseResult = getResultFromPrevIfElse( sagaAction.ChildSteps, step, sagaState); // jesli if-else jest spelniony to nie wchodzimy juz do niego // czyli szukamy kolengo kroku poza if-else if (ifElseResult) { ISagaStep nextStepAfterIfElse = GetNextStepAfterIfElse( sagaAction.ChildSteps, step); if (nextStepAfterIfElse != null) { return(nextStepAfterIfElse); } } return(getNextStep(sagaAction, step, sagaState)); } return(step); }
static ISagaStep GetNextStepAfterIfElse( SagaSteps childSteps, ISagaStep step) { while (true) { ISagaStep nextStep = GetNextStepSameLevel(childSteps, step); if (nextStep.Is <ISagaStepForIf>() && nextStep.Is <ISagaStepForElse>()) { step = nextStep; } else if (!nextStep.Is <ISagaStepForIf>() && nextStep.Is <ISagaStepForElse>()) { step = nextStep; } else { return(nextStep); } } }