Table of Contents

Class CommonIterator<TIteratorType>

Namespace
MASES.KNet.Streams.State
Assembly
MASES.KNet.dll

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 IGenericSerDesFactory

The IGenericSerDesFactory associated to this instance

Properties

Factory

Returns the current IGenericSerDesFactory

protected IGenericSerDesFactory Factory { get; }

Property Value

IGenericSerDesFactory

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

bool

Methods

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that iterates asynchronously through the collection.

public IAsyncEnumerator<TIteratorType> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A 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 bool

true if requesting an IAsyncEnumerator<T>

usePrefetch bool

true if requesting prefetch behavior

cancellationToken CancellationToken

The CancellationToken to be used in IAsyncEnumerator<T>

Returns

object

An IEnumerable<T> or IAsyncEnumerable<T>

ToIEnumerator(bool)

Returns an IEnumerator<T> of TIteratorType

public IEnumerator<TIteratorType> ToIEnumerator(bool usePrefetch = true)

Parameters

usePrefetch bool

true 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