public bool MoveNext()
{
if (_needFirst)
{
// Get first matching preceding-sibling node
if (!_navCurrent.MoveToParent())
{
return(false);
}
if (!_filter.MoveToContent(_navCurrent))
{
return(false);
}
_needFirst = false;
}
else
{
// Get next matching preceding-sibling node
if (!_filter.MoveToFollowingSibling(_navCurrent))
{
return(false);
}
}
// Accept matching sibling only if it precedes navEnd in document order
if (_useCompPos)
{
return(_navCurrent.ComparePosition(_navEnd) == XmlNodeOrder.Before);
}
if (_navCurrent.IsSamePosition(_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.
_useCompPos = true;
return(false);
}
return(true);
}