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 ISagaStep GetNextStepElsewhere( SagaSteps SagaSteps, ISagaStep stepToFind, Boolean onTheSameLevel = false) { ISagaStep parentStep = stepToFind?.ParentStep; bool stepFound = false; if (parentStep == null) { foreach (ISagaStep childStep in SagaSteps) { if (stepFound) { return(childStep); } if (childStep == stepToFind) { stepFound = true; } } return(null); } else { foreach (ISagaStep childStep in parentStep.ChildSteps) { if (stepFound) { return(childStep); } if (childStep == stepToFind) { stepFound = true; } } if (stepFound && onTheSameLevel) { return(null); } return(GetNextStepElsewhere(SagaSteps, stepToFind.ParentStep, onTheSameLevel)); } }
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); } } }
public SagaAction() { ChildSteps = new SagaSteps(); }
static ISagaStep GetNextStepSameLevel( SagaSteps SagaSteps, ISagaStep stepToFind) { return(GetNextStepElsewhere(SagaSteps, stepToFind, true)); }