当前位置: 首页>>代码示例>>C#>>正文


C# XContainer.Nodes方法代码示例

本文整理汇总了C#中System.Xml.Linq.XContainer.Nodes方法的典型用法代码示例。如果您正苦于以下问题:C# XContainer.Nodes方法的具体用法?C# XContainer.Nodes怎么用?C# XContainer.Nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XContainer的用法示例。


在下文中一共展示了XContainer.Nodes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XContainer

 /// <summary>
 /// Clone ctor
 /// </summary>
 internal XContainer(XContainer source)
 {
     content = source.content as string;
     if ((content == null) && (source.content is XNode))
     {
         foreach (var node in source.Nodes())
         {
             Add(node.Clone(), false);
         }
     }
 }
开发者ID:nguyenkien,项目名称:api,代码行数:14,代码来源:XContainer.cs

示例2: ReplaceWithExpValues

 private IEnumerable<ExpectedValue> ReplaceWithExpValues(XContainer elem, XNode toReplace, IEnumerable<object> replacement)
 {
     foreach (XNode n in elem.Nodes())
     {
         if (n != toReplace)
         {
             yield return new ExpectedValue(true, n);
         }
         else
         {
             foreach (object o in replacement)
             {
                 yield return new ExpectedValue(o is XNode && (o as XNode).Parent == null && (o as XNode).Document == null, o);
             }
         }
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:17,代码来源:XNodeReplace.cs

示例3: CalculateExpectedContent

        private IEnumerable<ExpectedValue> CalculateExpectedContent(XContainer orig, IEnumerable<object> newNodes, string stringOnlyContent)
        {
            if (stringOnlyContent == null)
            {
                foreach (object o in orig.Nodes())
                {
                    yield return new ExpectedValue(true, o);
                }
            }
            else
            {
                yield return new ExpectedValue(false, new XText(stringOnlyContent));
            }

            foreach (object n in newNodes.Flatten())
            {
                if (n is XAttribute)
                {
                    continue;
                }
                yield return new ExpectedValue((n is XNode) && (n as XNode).Parent == null && (n as XNode).Document == null, n);
            }
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:23,代码来源:XContainerAddIntoElement.cs

示例4: GetInnerText

		string GetInnerText (XContainer node)
		{
			StringBuilder sb = null;
			foreach (XNode n in node.Nodes ())
				GetInnerText (n, ref sb);
			return sb != null ? sb.ToString () : String.Empty;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:XNodeNavigator.cs

示例5: TextValue

 private string TextValue(XContainer elem)
 {
     return elem.Nodes().OfType<XText>().Aggregate("", (s, text) => s + text);
 }
开发者ID:provegard,项目名称:testness,代码行数:4,代码来源:XUnitReporterTest.cs

示例6: DoRemoveTest

        private void DoRemoveTest(XContainer elem, int position)
        {
            List<ExpectedValue> expectedData = elem.Nodes().Take(position).Concat(elem.Nodes().Skip(position + 1)).Select(n => new ExpectedValue(!(n is XText), n)).ProcessNodes().ToList();

            XNode toRemove = elem.Nodes().ElementAt(position);
            toRemove.Remove();

            TestLog.Compare(toRemove.Parent == null, "Parent of Removed");
            TestLog.Compare(toRemove.Document == null, "Document of Removed");
            TestLog.Compare(toRemove.NextNode == null, "NextNode");
            TestLog.Compare(toRemove.PreviousNode == null, "PreviousNode");
            if (toRemove is XContainer)
            {
                foreach (XNode child in (toRemove as XContainer).Nodes())
                {
                    TestLog.Compare(child.Document == null, "Document of child of Removed");
                    TestLog.Compare(child.Parent == toRemove, "Parent of child of Removed should be set");
                }
            }
            // try Remove Removed node
            try
            {
                toRemove.Remove();
                TestLog.Compare(false, "Exception expected [" + toRemove.NodeType + "] " + toRemove);
            }
            catch (InvalidOperationException)
            {
            }

            TestLog.Compare(expectedData.EqualAll(elem.Nodes(), XNode.EqualityComparer), "The rest of the tree - Nodes()");
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:31,代码来源:XNodeRemove.cs

示例7: ParseNodes

        private IEnumerable<TokenBase> ParseNodes(XContainer container, Stack<TextVisualProperties> propertiesStack, TokenIndex top, int bookLevel, int parentID = -1)
        {
            foreach (XNode node in container.Nodes())
            {
                var text = node as XText;
                if ((text != null) && !string.IsNullOrEmpty(text.Value))
                {
                    foreach (TokenBase token in ParseText(text.Value, top))
                    {
                        yield return token;
                    }
                }
                var element = node as XElement;
                if(element == null)
                    continue;

                TextVisualProperties properties = propertiesStack.Peek().Clone().Update(element, _styleSheet);
                
                string localName = element.Name.LocalName;
                int level = bookLevel;

                if (localName == "a")
                {
                    ProcessLinks(properties, element);
                }
                ProcessAnchors(top, element);

                if (localName == "section")
                {
                    yield return new NewPageToken(top.Index++);
                    level++;
                }

                if (localName == "title")
                {
                    ProcessTitleData(top, element, level);
                }

                if (localName == "image")
                {
                    XAttribute hrefAttr = element.Attributes().FirstOrDefault(t => (t.Name.LocalName == "href"));
                    string href = ((hrefAttr != null) ? hrefAttr.Value : string.Empty).TrimStart('#');
                    var pictureToken = new PictureToken(top.Index++, href);
                    yield return pictureToken;
                }
                else
                {
                    var tagOpen = new TagOpenToken(top.Index++, element, properties, parentID);
                    yield return tagOpen;

                    propertiesStack.Push(properties);
                    foreach (TokenBase token in ParseNodes(element, propertiesStack, top, level, tagOpen.ID))
                    {
                        yield return token;
                    }
                    propertiesStack.Pop();

                    yield return new TagCloseToken(top.Index++, parentID);
                }
                
            }
        }
开发者ID:bdvsoft,项目名称:reader_wp8_OPDS,代码行数:62,代码来源:Fb2TokenParser.cs

示例8: ReparentChildren

		private static void ReparentChildren(
				XContainer originalParent, XContainer newParent)
		{
			// re-parent all descendants from originalParent into newParent
			List<XNode> childNodes = new List<XNode>();
			foreach (XNode d in originalParent.Nodes())
			{
				childNodes.Add(d);
			}
			foreach (XNode d in childNodes)
			{
				d.Remove();
				newParent.Add(d);
			}
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:15,代码来源:EdmGen2.cs

示例9: SelectDirectDescendents

		private static IEnumerable<XElement> SelectDirectDescendents(
			 XContainer root, XName name)
		{
			List<XElement> selected = new List<XElement>();
			foreach (XNode node in root.Nodes())
			{
				if (node.NodeType == XmlNodeType.Element)
				{
					XElement e = node as XElement;
					if (e != null)
					{
						if (e.Name.Equals(name))
						{
							selected.Add(e);
						}
					}
				}
			}
			return selected;
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:20,代码来源:EdmGen2.cs

示例10: TransferChildren

		private static void TransferChildren(
			 XContainer originalParent, XContainer newParent)
		{
			// now move all descendants into this node
			List<XNode> childNodes = new List<XNode>();
			foreach (XNode d in originalParent.Nodes())
			{
				childNodes.Add(d);
			}
			foreach (XNode d in childNodes)
			{
				d.Remove();
				newParent.Add(d);
			}
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:15,代码来源:EdmGen2.cs

示例11: AddLeadingIndentation

 private static void AddLeadingIndentation(XContainer container, string containerIndent, string oneIndentLevel)
 {
     var containerIsSelfClosed = !container.Nodes().Any();
     var lastChildText = container.LastNode as XText;
     if (containerIsSelfClosed || lastChildText == null)
     {
         container.Add(new XText(containerIndent + oneIndentLevel));
     }
     else
     {
         lastChildText.Value += oneIndentLevel;
     }
 }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:13,代码来源:XmlUtility.cs


注:本文中的System.Xml.Linq.XContainer.Nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。