MimeIteratorGetAncestor Method

Get an ancestor of the current entity.

Definition

Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public MimeEntity GetAncestor(
	int generation
)

Parameters

generation  Int32
The number of generations above the current entity, between 1 and Depth.

Return Value

MimeEntity
The ancestor.

Remarks

Gets the ancestor of the current entity that is the specified number of generations above it: a generation of 1 gets the Parent, 2 gets the parent of the parent, and Depth gets the body of the top-level message.

This can be used, for example, to determine whether the current entity is contained within a MultipartAlternative.

Exceptions

ArgumentOutOfRangeException generation is less than 1 or greater than Depth.
InvalidOperationException Either MoveNext has not been called or MoveNext has moved beyond the end of the message.

See Also