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


C# XComment.Remove方法代码示例

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


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

示例1: MultiUnicodeHasCorrectRepsonses

		public void MultiUnicodeHasCorrectRepsonses()
		{
			const string str = @"<CmPossibilityList
						guid='cf379f73-9ee5-4e45-b2e2-4b169666d83e'>
		<Name>
			<AUni
				ws='en'>Genres &amp;</AUni>
			<AUni
				ws='es'>Géneros &amp;</AUni>
		</Name>
						</CmPossibilityList>";
			var element = XElement.Parse(str);
			AddBasicPropertyElementsToPossList(element);
			var result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNull(result);

			element.Element("Name").Add(new XAttribute("bogusAttr", "badvalue"));
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNotNull(result);
			Assert.IsTrue(result.Contains("Has unrecognized attribute(s)"));
			element.Element("Name").Attributes().Remove();

			element.Element("Name").Add(new XElement("extraChild"));
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNotNull(result);
			Assert.IsTrue(result.Contains("Has non-AUni child element"));
			element.Element("Name").Element("extraChild").Remove();

			element.Element("Name").Element("AUni").Add(new XAttribute("bogusAttr", "badValue"));
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNotNull(result);
			Assert.IsTrue(result.Contains("Has too many attributes"));
			var wsAttr = element.Element("Name").Element("AUni").Attribute("ws");
			wsAttr.Remove();
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNotNull(result);
			Assert.IsTrue(result.Contains("Does not have required 'ws' attribute"));
			element.Element("Name").Element("AUni").Attribute("bogusAttr").Remove();
			element.Element("Name").Element("AUni").Add(wsAttr);
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNull(result);

			var extraChild = new XElement("extraChild");
			element.Element("Name").Element("AUni").Add(extraChild);
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNotNull(result);
			Assert.IsTrue(result.Contains("Has non-text child element"));
			extraChild.Remove();

			// Comment doesn't count, as trouble.
			var comment = new XComment("Some comment.");
			element.Element("Name").Element("AUni").Add(comment);
			result = CmObjectValidator.ValidateObject(_mdc, element);
			Assert.IsNull(result);
			comment.Remove();
		}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:56,代码来源:CmObjectValidatorTests.cs

示例2: NodeRemove

        public void NodeRemove()
        {
            XElement parent = new XElement("parent");

            XComment child1 = new XComment("child1");
            XText child2 = new XText("child2");
            XElement child3 = new XElement("child3");

            parent.Add(child1, child2, child3);

            // Sanity check
            Assert.Equal(parent.Nodes(), new XNode[] { child1, child2, child3 }, XNode.EqualityComparer);

            // Remove the text.
            child1.NextNode.Remove();
            Assert.Equal(new XNode[] { child1, child3 }, parent.Nodes(), XNode.EqualityComparer);

            // Remove the XComment.
            child1.Remove();
            Assert.Equal(new XNode[] { child3 }, parent.Nodes(), XNode.EqualityComparer);

            // Remove the XElement.
            child3.Remove();
            Assert.Empty(parent.Nodes());
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:25,代码来源:SDMNode.cs

示例3: NodeRemove

                /// <summary>
                /// Tests Remove on Node.
                /// </summary>
                /// <param name="context"></param>
                /// <returns></returns>
                //[Variation(Desc = "NodeRemove")]
                public void NodeRemove()
                {
                    XElement parent = new XElement("parent");

                    XComment child1 = new XComment("child1");
                    XText child2 = new XText("child2");
                    XElement child3 = new XElement("child3");

                    parent.Add(child1, child2, child3);

                    // Sanity check
                    Validate.EnumeratorDeepEquals(parent.Nodes(), new XNode[] { child1, child2, child3 });

                    // Remove the text.
                    child1.NextNode.Remove();
                    Validate.EnumeratorDeepEquals(parent.Nodes(), new XNode[] { child1, child3 });

                    // Remove the XComment.
                    child1.Remove();
                    Validate.EnumeratorDeepEquals(parent.Nodes(), new XNode[] { child3 });

                    // Remove the XElement.
                    child3.Remove();
                    Validate.EnumeratorDeepEquals(parent.Nodes(), new XNode[] { });
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:31,代码来源:SDMNode.cs

示例4: Element6

                //[Variation(Priority = 0, Desc = "XElement - text node incarnation - by touching", Param = 1)]
                //[Variation(Priority = 0, Desc = "XElement - text node incarnation - by adding new node", Param = 2)]
                public void Element6()
                {
                    XElement e1 = new XElement("A", "datata");
                    XElement e2 = new XElement("A", "datata");
                    switch ((int)Variation.Param)
                    {
                        case 1:
                            XComment c = new XComment("hele");
                            e2.Add(c);
                            c.Remove();
                            break;
                        case 2:
                            break;
                        default:
                            TestLog.Compare(false, "Unexpected value - test failed");
                            break;
                    }

                    VerifyComparison(true, e1, e2);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:22,代码来源:DeepEquals.cs


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