public abstract class YieldEnumeratorWithParent<P> : IEnumerator<YieldInstruction>
This class is effectively the same as YieldEnumerator,
except it includes a field to store the Parent of your custom enumerator. This
allows you to access the parent instance and any fields/methods it has from within
the MoveNextImplementation method.
The type parameter P is the type of the parent which your custom class is created
in. If you want to actually make use of this
parent (for accessing instance fields or methods within the MoveNextImplementation),
pass it into the PrepareForIteration method.
Name | Type | Description |
---|---|---|
Parent | P |
Gets the parent of your custom YieldEnumeratorWithParent class. Classes deriving from this one can and should null the Parent in their NulRefFields method. There is no need to set the Parent, simply call PrepareForIteration that uses a single P type parameter. |
Prepares the enumerator for iteration by passing in the parent reference of the enumerator, so that it can be used by the enumerator within it's PrepareForIteration or MoveNextImplementation methods.
Name | Type | Description |
---|---|---|
parent |
The parent reference. |
Nulls the Parent reference and calls NullRefFieldsAdditional so that additional references can be nulled in sub classes.
Can be overriden in sub classes to null additional reference fields. If using one of the generic sub classes, you don't need to implement this, as it is implemented already to null out the fields indicated by the generic reference types.