private IEnumerator OnIteration(int index) { RockLog.InsertLine(); RockLog.WriteLine(this, LogTier.Info, string.Format("Starting iteration number: {0}", CurrentIteration)); InnerScope.Reset(); var iteratorVariable = Field <object> .Create(RepeatNumberName, index, false, true); // update the iterator job context InnerScope.ScopeContext.Add(iteratorVariable); // reset the inner scope and loop through the child steps yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this)); if (!IsSuppressed) { switch (InnerScope.Request) { case StepRequest.ExitScope: case StepRequest.RootScope: case StepRequest.TerminateJob: DoLoop = false; break; } } CurrentIteration++; }
/// <summary> /// Resets the loop. /// </summary> protected override void OnReset() { DoLoop = true; TotalItemsCount = 0; if (ItemList != null) { TotalItemsCount = ItemList.Count(); } CurrentIteration = 0; InnerScope.Reset(); }
/// <inheritdoc /> /// <summary> /// Called when this Step gets executed. /// </summary> /// <param name="context">Current job context.</param> /// <returns></returns> protected override IEnumerator OnExecute(JobContext context) { InnerScope.ScopeContext = new JobContext(context); if (InnerScope.Steps.Count == 0) { IsSuccess = true; yield break; } foreach (var item in ItemList) { if (!DoLoop) { break; } OnIterationStart(CurrentIteration); InnerScope.Reset(); var iteratorVariable = Field <object> .Create(IteratorName.Trim('%'), item, false, true); var indexCountVariable = Field <object> .Create(IndexCountName.Trim('%'), CurrentIteration, false, true); // update the iterator job context InnerScope.ScopeContext.Add(iteratorVariable); InnerScope.ScopeContext.Add(indexCountVariable); // reset the inner scope and loop through the child steps yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this)); OnIterationEnd(CurrentIteration); if (!IsSuppressed) { switch (InnerScope.Request) { case StepRequest.ExitScope: case StepRequest.RootScope: case StepRequest.TerminateJob: DoLoop = false; break; } } CurrentIteration++; } IsSuccess = true; yield return(null); }
/// <summary> /// Resets the loop. /// </summary> protected override void OnReset() { DoLoop = true; CurrentIteration = 0; InnerScope.Reset(); }
/// <inheritdoc /> protected override void OnReset() { InnerScope.Reset(); }