/// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.IsSamePosition" /> for details. /// </summary> /// <returns>Returns <see langword="true"/> if this navigator is positioned /// at the same node as other navigator, and <see langword="false"/> /// otherwise.</returns> public override bool IsSamePosition( XPathNavigator other ) { #if DEBUG Trace( () => string.Format( "IsSamePosition( N#{0} )", other.GetHashCode() ) ); #endif var x = other as ObjectXPathNavigator; if( x == null ) return false; if( _context != x._context ) return false; // Compare child navigators if( _childNav != null ) return x._childNav != null && _childNav.IsSamePosition( x._childNav ); if( x._childNav != null ) // In case if our navigator is null and other is not. return false; return _node == x._node; }
/// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveTo" /> for details. /// </summary> public override bool MoveTo( XPathNavigator other ) { var otherNav = other as ObjectXPathNavigator; if( otherNav == null ) return false; _context = otherNav._context; _root = otherNav._root; _node = otherNav._node; if( otherNav._childNav != null ) { _childNav = otherNav._childNav.Clone(); _childNavDepth = otherNav._childNavDepth; } else _childNav = null; #if DEBUG Trace( () => string.Format( "MoveTo( N#{0} )", other.GetHashCode() ) ); #endif if( _context.DetectLoops ) _navigationStack = (Stack)otherNav._navigationStack.Clone(); return true; }
/// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.IsSamePosition" /> for details. /// </summary> /// <returns>Returns <see langword="true"/> if this navigator is positioned /// at the same node as other navigator, and <see langword="false"/> /// otherwise.</returns> public override bool IsSamePosition(XPathNavigator other) { #if DEBUG Trace(() => string.Format("IsSamePosition( N#{0} )", other.GetHashCode())); #endif ObjectXPathNavigator x = other as ObjectXPathNavigator; if (x == null) { return false; } if (_context != x._context) return false; // Compare child navigators if (_childNav != null) { if (x._childNav != null) // Both child navigators are not null return _childNav.IsSamePosition(x._childNav); else // Our navigator is not null, but other is null; return false; } else if (x._childNav != null) // In case if our navigator is null and other is not. return false; if (_node != x._node) return false; return true; }