public static async Task MoveForward <TStepId, TData>(MoveToStepContext <TStepId, TData> context) #endif { IStepEnumerator <TStepId, TData> stepEnumerator = context.Session.StepEnumerator; IMoveInfo <TStepId> moveInfo = context.Session.MoveInfo; int moveCount = 0; do { stepEnumerator.MoveNext(); ++moveCount; }while (stepEnumerator.CurrentStep != null && !moveInfo.Comparer.Equals(stepEnumerator.CurrentStep.Id, moveInfo.Id)); context.Session.MoveInfo = null; if (stepEnumerator.CurrentStep == null) { for (int i = 0; i < moveCount; ++i) { stepEnumerator.MovePrevious(); } #if NET35 || NOASYNC RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #else await RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #endif { Result = ResultType.Failed, CaughtException = new InvalidOperationException(string.Format("Could not move forward to a step with id '{0}' as the step does not exist.", moveInfo.Id)), Session = context.Session }); return; } #if NET35 || NOASYNC context.MoveToStepFinishAction(); #else await context.MoveToStepFinishAction(); #endif }
/// <summary> /// Returns a value indicating whether the step enumerator is set to the first step. /// </summary> /// <typeparam name="TStepId">The type of the step id.</typeparam> /// <typeparam name="TData">The type of the transaction data.</typeparam> /// <param name="stepEnumerator">The step enumerator.</param> /// <returns><c>True</c> if the step enumerator is set to the first step, otherwise <c>false</c>.</returns> public static bool IsFirstStep <TStepId, TData>(this IStepEnumerator <TStepId, TData> stepEnumerator) { return(stepEnumerator.CurrentStepIndex == 0); }