Skip to content

SpeakableEnumerator<TCurrent> Class

A class that wraps an IEnumerator<T> object. Allows access to basic fields of the IEnumerator.

C#
public sealed class SpeakableEnumerator<TCurrent> : ISpeakableEnumerator

TCurrent
The type of Current.

Inheritance object

Implements ISpeakableEnumerator

SpeakableEnumerator(IEnumerator<TCurrent>)

Section titled “SpeakableEnumerator(IEnumerator<TCurrent>)”

A class that wraps an IEnumerator<T> object. Allows access to basic fields of the IEnumerator.

C#
public SpeakableEnumerator(IEnumerator<TCurrent> instance)

instance IEnumerator<TCurrent>
An enumerator instance.

Gets the instance of the IEnumerator wrapped by this class. Note that this is not the instance of the class that constructed this enumerator.

C#
public IEnumerator<TCurrent> Enumerator { get; }

The Current value of this enumerator.
This corresponds to the <>2__current field.

C#
public TCurrent Current { get; set; }

The state value of this enumerator.
This corresponds to the <>1__state field.

C#
public int State { get; set; }

Can be used for building field reference getter methods ahead-of-time to prevent a freeze that would happen when building them just-in-time.

C#
public static void PreBuildFieldReferenceGetters(Type type)

type Type
The type of Enumerator to build field reference getters for.

NullReferenceException

InvalidCastException

MonoDetour already uses this where it uses SpeakableEnumerator types.

Gets or creates a SpeakableEnumerator<TCurrent> for the specified instance.

C#
public static SpeakableEnumerator<TCurrent> GetOrCreate(IEnumerator<TCurrent> instance)

instance IEnumerator<TCurrent>
An enumerator instance.

SpeakableEnumerator<TCurrent>
A new or existing SpeakableEnumerator<TCurrent>.