public override bool MoveToNextAttribute() {
switch (this.state) {
case State.Content:
return MoveToFirstAttribute();
case State.Attribute: {
if (XPathNodeType.Attribute == this.nav.NodeType)
return this.nav.MoveToNextAttribute();
// otherwise it is on a namespace... namespace are in reverse order
Debug.Assert( XPathNodeType.Namespace == this.nav.NodeType );
XPathNavigator nav = this.nav.Clone();
if ( !nav.MoveToParent() )
return false; // shouldn't happen
if ( !nav.MoveToFirstNamespace( XPathNamespaceScope.Local ) )
return false; // shouldn't happen
if ( nav.IsSamePosition( this.nav ) ) {
// this was the last one... start walking attributes
nav.MoveToParent();
if (!nav.MoveToFirstAttribute())
return false;
// otherwise we are there
this.nav.MoveTo(nav);
return true;
}
else {
XPathNavigator prev = nav.Clone();
for (;;) {
if ( !nav.MoveToNextNamespace( XPathNamespaceScope.Local ) ) {
Debug.Fail( "Couldn't find Namespace Node! Should not happen!" );
return false;
}
if ( nav.IsSamePosition( this.nav ) ) {
this.nav.MoveTo(prev);
return true;
}
prev.MoveTo( nav );
}
// found previous namespace position
}
}
case State.AttrVal:
depth--;
this.state = State.Attribute;
if (!MoveToNextAttribute()) {
depth++;
this.state = State.AttrVal;
return false;
}
this.nodeType = XmlNodeType.Attribute;
return true;
case State.InReadBinary:
state = savedState;
if (!MoveToNextAttribute()) {
state = State.InReadBinary;
return false;
}
readBinaryHelper.Finish();
return true;
default:
return false;
}
}