/// <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;
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
        /// <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;
        }
Пример #5
0
 /// <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;
 }
Пример #7
0
 /// <summary>Disposes of the enumerator.</summary>
 public void Dispose()
 {
     while (stateQueue.Count > 0)
     {
         stateQueue.Dequeue().Enumerator.Dispose();
     }
     current           = null;
     currentState      = null;
     currentEnumerator = null;
 }
Пример #8
0
 /// <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;
 }
Пример #10
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;
 }
Пример #11
0
        /// <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;
        }
        /// <summary>
        /// Adds the current result as a new enumeration state.<para/>
        /// Switches to this state if the curren search is just subdirectories only.
        /// </summary>
        private void AddState()
        {
            var newState = new EnumerationInfoState(currentEnumerator.Current.FullName, search);

            stateList.Insert(stateIndex + ++currentState.SubdirCount, newState);
        }
Пример #13
0
        /// <summary>Enqueues the current result as a new enumeration state.</summary>
        private void EnqueueState()
        {
            var newState = new EnumerationInfoState(currentEnumerator.Current.FullName, search);

            stateQueue.Enqueue(newState);
        }