public override bool MoveToFollowing(XPathNodeType type, XPathNavigator end) {
XmlNode pastFollowing = null;
DocumentXPathNavigator that = end as DocumentXPathNavigator;
if (that != null) {
if (document != that.document) {
return false;
}
switch (that.source.NodeType) {
case XmlNodeType.Attribute:
that = (DocumentXPathNavigator)that.Clone();
if (!that.MoveToNonDescendant()) {
return false;
}
break;
}
pastFollowing = that.source;
}
int mask = GetContentKindMask(type);
if (mask == 0) {
return false;
}
XmlNode following = source;
switch (following.NodeType) {
case XmlNodeType.Attribute:
following = ((XmlAttribute)following).OwnerElement;
if (following == null) {
return false;
}
break;
case XmlNodeType.Text:
case XmlNodeType.CDATA:
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Whitespace:
following = TextEnd(following);
break;
}
do {
XmlNode firstChild = following.FirstChild;
if (firstChild != null) {
following = firstChild;
}
else {
for (;;) {
XmlNode nextSibling = following.NextSibling;
if (nextSibling != null) {
following = nextSibling;
break;
}
else {
XmlNode parent = following.ParentNode;
if (parent != null) {
following = parent;
}
else {
return false;
}
}
}
}
if (following == pastFollowing) {
return false;
}
}
while (((1 << (int)following.XPNodeType) & mask) == 0);
source = following;
return true;
}