Class CommonIterator<TIteratorType>
A common class for all iterators
public abstract class CommonIterator<TIteratorType> : IGenericSerDesFactoryApplier, IEnumerable<TIteratorType>, IEnumerable, IAsyncEnumerable<TIteratorType>
Type Parameters
TIteratorType
The return Type of IEnumerable<T> and IAsyncEnumerable<T>
- Inheritance
-
CommonIterator<TIteratorType>
- Implements
-
IEnumerable<TIteratorType>IAsyncEnumerable<TIteratorType>
- Derived
- Inherited Members
Constructors
CommonIterator(IGenericSerDesFactory)
Initialize a new instance of CommonIterator<TIteratorType>
protected CommonIterator(IGenericSerDesFactory factory)
Parameters
factory
IGenericSerDesFactoryThe IGenericSerDesFactory associated to this instance
Properties
Factory
Returns the current IGenericSerDesFactory
protected IGenericSerDesFactory Factory { get; }
Property Value
UsePrefetch
Used to get or set the type of enumerator to retrieve, default is with prefetch if the platform accept it
public bool UsePrefetch { get; set; }
Property Value
Methods
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<TIteratorType> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken that may be used to cancel the asynchronous iteration.
Returns
- IAsyncEnumerator<TIteratorType>
An enumerator that can be used to iterate asynchronously through the collection.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TIteratorType> GetEnumerator()
Returns
- IEnumerator<TIteratorType>
An enumerator that can be used to iterate through the collection.
GetEnumerator(bool, bool, CancellationToken)
Internally gets the IEnumerable<T> or IAsyncEnumerable<T>
protected abstract object GetEnumerator(bool isAsync, bool usePrefetch, CancellationToken cancellationToken = default)
Parameters
isAsync
booltrue if requesting an IAsyncEnumerator<T>
usePrefetch
booltrue if requesting prefetch behavior
cancellationToken
CancellationTokenThe CancellationToken to be used in IAsyncEnumerator<T>
Returns
ToIEnumerator(bool)
Returns an IEnumerator<T> of TIteratorType
public IEnumerator<TIteratorType> ToIEnumerator(bool usePrefetch = true)
Parameters
usePrefetch
booltrue to return an IEnumerator<T> making preparation of
TIteratorType
in parallel
Returns
- IEnumerator<TIteratorType>
An IEnumerator<T> of
TIteratorType
Remarks
usePrefetch
is not considered with .NET 6 and .NET Framework