public bool MoveNext() {
if (this.needFirst) {
// Get first matching preceding-sibling node
if (!this.navCurrent.MoveToParent())
return false;
if (!this.filter.MoveToContent(this.navCurrent))
return false;
this.needFirst = false;
}
else {
// Get next matching preceding-sibling node
if (!this.filter.MoveToFollowingSibling(this.navCurrent))
return false;
}
// Accept matching sibling only if it precedes navEnd in document order
if (this.useCompPos)
return (this.navCurrent.ComparePosition(this.navEnd) == XmlNodeOrder.Before);
if (this.navCurrent.IsSamePosition(this.navEnd)) {
// Found the original context node, so iteration is complete. If MoveNext
// is called again, use ComparePosition so that false will continue to be
// returned.
this.useCompPos = true;
return false;
}
return true;
}