/// <summary> /// Sets the enumerator to its initial position, which is before the first file in the /// directory. /// </summary> public void Reset() { Dispose(); currentState = new EnumerationInfoState(search); currentEnumerator = currentState.Enumerator; stateList.Add(currentState); }
/// <summary> /// Ends the current state and procedes to the next available state.<para/> /// If there are no states after this one in the list, then the state list is backtracked. /// </summary> private void NextState() { // Cleanup the current enumerator. currentEnumerator.Dispose(); // Remove the current state stateList.RemoveAt(stateIndex); if (stateIndex == stateList.Count) { // We've hit the end, recurse backwards to find // states that haven't finished subdir scans. if (stateList.Count > 0) { currentState = stateList[--stateIndex]; } else // End of the line, pal { currentState = null; } } else { // Goto the next available queued state currentState = stateList[stateIndex]; } // Assign the shortcut to the current enumerator currentEnumerator = currentState?.Enumerator; }
/// <summary>Constructs the <see cref="AllDepthsInfoEnumerator"/>.</summary> /// /// <param name="search">The information about the search.</param> public AllDepthsInfoEnumerator(SearchInfo search) { this.search = search; currentState = new EnumerationInfoState(search); currentEnumerator = currentState.Enumerator; stateQueue = new Queue <EnumerationInfoState>(); stateQueue.Enqueue(currentState); }
/// <summary> /// Pushes the current result as a new enumeration state and Immediately switches to it. /// </summary> private void PushState() { var newState = new EnumerationInfoState(currentEnumerator.Current.FullName, search); stateStack.Push(newState); currentState = newState; currentEnumerator = newState.Enumerator; }
/// <summary>Constructs the <see cref="AllSubdirectoriesInfoEnumerator"/>.</summary> /// /// <param name="search">The information about the search.</param> public AllSubdirectoriesInfoEnumerator(SearchInfo search) { this.search = search; currentState = new EnumerationInfoState(search); currentEnumerator = currentState.Enumerator; stateStack = new Stack <EnumerationInfoState>(); stateStack.Push(currentState); }
/// <summary>Constructs the <see cref="AllDirectoriesInfoEnumerator"/>.</summary> /// /// <param name="search">The information about the search.</param> public AllDirectoriesInfoEnumerator(SearchInfo search) { this.search = search; currentState = new EnumerationInfoState(search); currentEnumerator = currentState.Enumerator; stateList = new List <EnumerationInfoState> { currentState }; stateIndex = 0; }
/// <summary>Disposes of the enumerator.</summary> public void Dispose() { while (stateQueue.Count > 0) { stateQueue.Dequeue().Enumerator.Dispose(); } current = null; currentState = null; currentEnumerator = null; }
/// <summary>Disposes of the enumerator.</summary> public void Dispose() { while (stateStack.Count > 0) { stateStack.Pop().Enumerator.Dispose(); } current = null; currentState = null; currentEnumerator = null; }
/// <summary>Disposes of the enumerator.</summary> public void Dispose() { for (int i = 0; i < stateList.Count; i++) { stateList[i].Enumerator.Dispose(); } stateList.Clear(); current = null; currentState = null; currentEnumerator = null; stateIndex = 0; }
/// <summary>Ends the current state and procedes to the next available state.</summary> private void DequeueState() { currentEnumerator.Dispose(); stateQueue.Dequeue(); if (stateQueue.Count > 0) { currentState = stateQueue.Peek(); } else { currentState = null; } currentEnumerator = currentState?.Enumerator; }
/// <summary>Ends the current state and backtracks to the last state.</summary> private void PopState() { // Cleanup the current enumerator. currentEnumerator.Dispose(); // Remove the current state stateStack.Pop(); if (stateStack.Count > 0) { currentState = stateStack.Peek(); } else // End of the line, pal { currentState = null; } // Assign the shortcut to the current enumerator currentEnumerator = currentState?.Enumerator; }