本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveTo方法的具体用法?C# XPathNavigator.MoveTo怎么用?C# XPathNavigator.MoveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.MoveTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetComments
/// <summary>
/// Gets the comments for inheritdoc node.
/// </summary>
/// <param name="iterator">Iterator for API information</param>
/// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
private void GetComments(XPathNodeIterator iterator, XPathNavigator inheritDocNodeNavigator)
{
foreach(XPathNavigator navigator in iterator)
{
XPathNavigator contentNodeNavigator = this.commentsIndex[navigator.Value];
if(contentNodeNavigator == null)
continue;
this.UpdateNode(inheritDocNodeNavigator, contentNodeNavigator);
if(this.sourceDocument.CreateNavigator().Select(inheritDocExpression).Count == 0)
break;
inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
}
}
示例2: SyncToNavigator
/// <summary>
/// Position navThis to the same location as navThat.
/// </summary>
internal static XPathNavigator SyncToNavigator(XPathNavigator navigatorThis, XPathNavigator navigatorThat) {
if (navigatorThis == null || !navigatorThis.MoveTo(navigatorThat))
return navigatorThat.Clone();
return navigatorThis;
}
示例3: UpdateNode
/// <summary>
/// Updates the node replacing inheritdoc node with comments found.
/// </summary>
/// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
/// <param name="contentNodeNavigator">Navigator for content</param>
private void UpdateNode(XPathNavigator inheritDocNodeNavigator, XPathNavigator contentNodeNavigator)
{
// retrieve the selection filter if specified.
string selectValue = inheritDocNodeNavigator.GetAttribute("select", string.Empty);
if(!string.IsNullOrEmpty(selectValue))
sourceExpression = XPathExpression.Compile(selectValue);
inheritDocNodeNavigator.MoveToParent();
if(inheritDocNodeNavigator.LocalName != "comments" && inheritDocNodeNavigator.LocalName != "element")
sourceExpression = XPathExpression.Compile(inheritDocNodeNavigator.LocalName);
else
inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
XPathNodeIterator sources = (XPathNodeIterator)contentNodeNavigator.CreateNavigator().Evaluate(sourceExpression);
inheritDocNodeNavigator.DeleteSelf();
// append the source nodes to the target node
foreach(XPathNavigator source in sources)
inheritDocNodeNavigator.AppendChild(source);
}
示例4: IsDescendant
private void IsDescendant (XPathNavigator nav)
{
XPathNavigator tmp = nav.Clone ();
XPathNodeIterator iter = nav.Select ("//e");
iter.MoveNext ();
Assert.IsTrue (nav.MoveTo (iter.Current), "#1");
Assert.IsTrue (nav.MoveToFirstAttribute (), "#2");
Assert.AreEqual ("attr", nav.Name, "#3");
Assert.AreEqual ("", tmp.Name, "#4");
Assert.IsTrue (tmp.IsDescendant (nav), "#5");
Assert.IsTrue (!nav.IsDescendant (tmp), "#6");
tmp.MoveToFirstChild ();
Assert.AreEqual ("a", tmp.Name, "#7");
Assert.IsTrue (tmp.IsDescendant (nav), "#8");
Assert.IsTrue (!nav.IsDescendant (tmp), "#9");
tmp.MoveTo (iter.Current);
Assert.AreEqual ("e", tmp.Name, "#10");
Assert.IsTrue (tmp.IsDescendant (nav), "#11");
Assert.IsTrue (!nav.IsDescendant (tmp), "#12");
}
示例5: MoveToNamespaces
private void MoveToNamespaces (XPathNavigator nav)
{
XPathNodeIterator iter = nav.Select ("//e");
iter.MoveNext ();
nav.MoveTo (iter.Current);
Assert.AreEqual ("e", nav.Name, "#1");
nav.MoveToFirstNamespace ();
Assert.AreEqual ("x", nav.Name, "#2");
nav.MoveToNextNamespace ();
Assert.AreEqual ("xml", nav.Name, "#3");
}
示例6: GetComments
/// <summary>
/// Gets the comments for inheritdoc node.
/// </summary>
/// <param name="iterator">Iterator for API information</param>
/// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
public void GetComments(XPathNodeIterator iterator, XPathNavigator inheritDocNodeNavigator)
{
foreach (XPathNavigator navigator in iterator)
{
XPathNavigator contentNodeNavigator = this.index.GetContent(navigator.Value);
if (contentNodeNavigator == null)
{
continue;
}
this.UpdateNode(inheritDocNodeNavigator, contentNodeNavigator);
if (this.sourceDocument.CreateNavigator().Select(inheritDocExpression).Count == 0)
{
break;
}
else
{
inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
}
}
}
示例7: IsDescendant
private void IsDescendant (XPathNavigator nav)
{
XPathNavigator tmp = nav.Clone ();
XPathNodeIterator iter = nav.Select ("//e");
iter.MoveNext ();
Assert (nav.MoveTo (iter.Current));
Assert (nav.MoveToFirstAttribute ());
AssertEquals ("attr", nav.Name);
AssertEquals ("", tmp.Name);
Assert (tmp.IsDescendant (nav));
Assert (!nav.IsDescendant (tmp));
tmp.MoveToFirstChild ();
AssertEquals ("a", tmp.Name);
Assert (tmp.IsDescendant (nav));
Assert (!nav.IsDescendant (tmp));
tmp.MoveTo (iter.Current);
AssertEquals ("e", tmp.Name);
Assert (tmp.IsDescendant (nav));
Assert (!nav.IsDescendant (tmp));
}