コード例 #1
0
        /// <summary>
        /// See <see cref="XPathNavigator.IsSamePosition"/>.
        /// </summary>
        public override bool IsSamePosition(XPathNavigator other)
        {
            if (other == null || !(other is SubtreeeXPathNavigator))
            {
                return(false);
            }

            SubtreeeXPathNavigator nav = (SubtreeeXPathNavigator)other;

            return(nav._atroot == this._atroot &&
                   nav._navigator.IsSamePosition(this._navigator) &&
                   nav._root.IsSamePosition(this._root));
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: zanyants/mvp.xml
		public void ExposingSubtreeXmlFragment()
		{
			string xml = @"
<library>
  <book genre='novel' ISBN='1-861001-57-5'>
     <title>Pride And Prejudice</title>
  </book>
  <book genre='novel' ISBN='1-81920-21-2'>
     <title>Hook</title>
  </book>
</library>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

			// <library>
			nav.MoveToFirstChild();
			// <book>
			nav.MoveToFirstChild();

			SubtreeeXPathNavigator sub = new SubtreeeXPathNavigator(nav, true);			
			// Enable fragment reading.
			XPathNavigatorReader reader = new XPathNavigatorReader(sub, true);
			reader.MoveToContent();
			string books = reader.ReadFragmentXml();

			sub.MoveToRoot();
			reader = new XPathNavigatorReader(sub, true);
			reader.MoveToContent();
			string books2 = reader.ReadFragmentXml();

			Assert.AreEqual(books, books2);
			Assert.AreEqual(
				"<book genre=\"novel\" ISBN=\"1-861001-57-5\"><title>Pride And Prejudice</title></book><book genre=\"novel\" ISBN=\"1-81920-21-2\"><title>Hook</title></book>", 
				books);
		}