Class CommonIterator<TIteratorType>
A common class for all iterators
public abstract class CommonIterator<TIteratorType> : IGenericSerDesFactoryApplier, IEnumerable<TIteratorType>, IEnumerable, IAsyncEnumerable<TIteratorType>, IDisposable, IAsyncDisposable
Type Parameters
TIteratorTypeThe return Type of IEnumerable<T> and IAsyncEnumerable<T>
- Inheritance
-
CommonIterator<TIteratorType>
- Implements
-
IEnumerable<TIteratorType>IAsyncEnumerable<TIteratorType>
- Derived
Constructors
CommonIterator(IGenericSerDesFactory)
Initialize a new instance of CommonIterator<TIteratorType>
protected CommonIterator(IGenericSerDesFactory factory)
Parameters
factoryIGenericSerDesFactoryThe 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
CheckDisposed()
Test if this instance was disposed
protected void CheckDisposed()
Exceptions
- ObjectDisposedException
When this instance was disposed
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Implements the pattern described in https://learn.microsoft.com/en-en/dotnet/standard/garbage-collection/implementing-dispose
protected virtual void Dispose(bool disposing)
Parameters
disposingboolThe disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<TIteratorType> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA 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
isAsyncbooltrue if requesting an IAsyncEnumerator<T>
usePrefetchbooltrue if requesting prefetch behavior
cancellationTokenCancellationTokenThe CancellationToken to be used in IAsyncEnumerator<T>
Returns
ToIEnumerator(bool)
Returns an IEnumerator<T> of TIteratorType
public IEnumerator<TIteratorType> ToIEnumerator(bool usePrefetch = true)
Parameters
usePrefetchbooltrue to return an IEnumerator<T> making preparation of
TIteratorTypein parallel
Returns
- IEnumerator<TIteratorType>
An IEnumerator<T> of
TIteratorType
Remarks
usePrefetch is not considered with .NET 6 and .NET Framework