Class BaseEnumerator<TEnumerable, TItem>
- Namespace
- Ecng.Collections
- Assembly
- Ecng.Collections.dll
Represents an abstract base class for an enumerator over a generic enumerable source.
public abstract class BaseEnumerator<TEnumerable, TItem> : SimpleEnumerator<TItem>, IEnumerator<TItem>, IEnumerator, IDisposable where TEnumerable : IEnumerable<TItem>
Type Parameters
TEnumerable
The type of the enumerable source, which must implement IEnumerable<T>.
TItem
The type of elements in the enumerable source.
- Inheritance
-
SimpleEnumerator<TItem>BaseEnumerator<TEnumerable, TItem>
- Implements
-
IEnumerator<TItem>
- Inherited Members
- Extension Methods
Constructors
BaseEnumerator(TEnumerable)
Initializes a new instance of the BaseEnumerator<TEnumerable, TItem> class with the specified source.
protected BaseEnumerator(TEnumerable source)
Parameters
source
TEnumerableThe enumerable source to iterate over.
Exceptions
- ArgumentException
Thrown when
source
is null.
Properties
Source
Gets or sets the enumerable source being iterated over.
public TEnumerable Source { get; }
Property Value
- TEnumerable
Methods
DisposeManaged()
Disposes of managed resources by resetting the enumerator and clearing the source.
protected override void DisposeManaged()
MoveNext()
Advances the enumerator to the next element of the collection.
public override bool MoveNext()
Returns
- bool
True if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
Exceptions
- ObjectDisposedException
Thrown if the enumerator has been disposed.
ProcessMove(ref bool)
Processes the movement to the next element and determines whether iteration can continue.
protected abstract TItem ProcessMove(ref bool canProcess)
Parameters
canProcess
boolA reference parameter indicating whether the enumerator can proceed; set to false if the end is reached.
Returns
- TItem
The next item in the collection, or the default value if no further items are available.
Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.
public override void Reset()