本文整理汇总了C#中System.Xml.Linq.XComment.NodesAfterSelf方法的典型用法代码示例。如果您正苦于以下问题:C# XComment.NodesAfterSelf方法的具体用法?C# XComment.NodesAfterSelf怎么用?C# XComment.NodesAfterSelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XComment
的用法示例。
在下文中一共展示了XComment.NodesAfterSelf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NodeContentAfterSelf
/// <summary>
/// Tests the ContentAfterSelf method on Node.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
//[Variation(Desc = "NodeContentAfterSelf")]
public void NodeContentAfterSelf()
{
XElement parent = new XElement("parent");
XComment child = new XComment("Self is a comment");
XComment comment1 = new XComment("Another comment");
XComment comment2 = new XComment("Yet another comment");
XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar"));
XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar"));
XAttribute attribute = new XAttribute("attribute", "value");
// If no parent, should not be any content after it.
Validate.Enumerator(child.NodesAfterSelf(), new XNode[0]);
// Add some content, including the child, and validate.
parent.Add(attribute);
parent.Add(comment1);
parent.Add(element1);
parent.Add(child);
parent.Add(comment2);
parent.Add(element2);
Validate.Enumerator(child.NodesAfterSelf(), new XNode[] { comment2, element2 });
}
示例2: NodeAllContentAfterSelf
/// <summary>
/// Tests the AllContentAfterSelf method on Node.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
//[Variation(Desc = "NodeAllContentAfterSelf")]
public void NodeAllContentAfterSelf()
{
XElement parent = new XElement("parent");
XComment child = new XComment("Self is a comment");
XComment comment1 = new XComment("Another comment");
XComment comment2 = new XComment("Yet another comment");
XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar"));
XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar"));
XAttribute attribute = new XAttribute("attribute", "value");
// If no parent, should not be any content after it.
Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]);
// Add child to parent. Should still be no content after it.
// Attributes are not content.
parent.Add(child);
parent.Add(attribute);
Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]);
// Add more children and validate.
parent.AddFirst(comment1);
parent.AddFirst(element1);
Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]);
parent.Add(element2);
parent.Add(comment2);
Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[] { element2, comment2 });
}