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


C# HtmlElement.ReplaceAttributes方法代码示例

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


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

示例1: ReplaceAttributes_DuplicateAttributeInAttribues_ThrowsInvalidOperationException

        public void ReplaceAttributes_DuplicateAttributeInAttribues_ThrowsInvalidOperationException()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlAttribute attribute = new HtmlAttribute("attribute");
            parent.Add(attribute);

            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAttributes(new HtmlAttribute[] { attribute }));
            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAttributes((IEnumerable<HtmlAttribute>)new HtmlAttribute[] { attribute }));
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElement.ReplaceTests.cs

示例2: ReplaceAttributes_NullAttributeInAttributes_ThrowsArgumentNullException

        public void ReplaceAttributes_NullAttributeInAttributes_ThrowsArgumentNullException()
        {
            HtmlElement parent = new HtmlElement("parent");

            Assert.Throws<ArgumentNullException>("content", () => parent.ReplaceAttributes(new HtmlAttribute[] { null }));
            Assert.Throws<ArgumentNullException>("content", () => parent.ReplaceAttributes((IEnumerable<HtmlAttribute>)new HtmlAttribute[] { null }));
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:7,代码来源:HtmlElement.ReplaceTests.cs

示例3: ReplaceAttributes_IEnumerableHtmlAttribute_VoidElement

        public void ReplaceAttributes_IEnumerableHtmlAttribute_VoidElement()
        {
            HtmlElement parent = new HtmlElement("br", isVoid: true);
            parent.Add(new HtmlAttribute("attribute1"));

            HtmlAttribute[] attributes = new HtmlAttribute[] { new HtmlAttribute("attribute2"), new HtmlAttribute("c") };
            parent.ReplaceAttributes((IEnumerable<HtmlAttribute>)attributes);
            Assert.Equal(attributes, parent.Attributes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElement.ReplaceTests.cs

示例4: ReplaceAttributes_IEnumerableHtmlAttribute

 public void ReplaceAttributes_IEnumerableHtmlAttribute(HtmlAttribute[] attributes)
 {
     HtmlElement element = new HtmlElement("parent", new HtmlElement("h1"), new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2"));
     element.ReplaceAttributes((IEnumerable<HtmlAttribute>)attributes);
     Assert.Equal(1, element.Elements().Count());
     Assert.Equal(attributes, element.Attributes().ToArray());
     Assert.Equal(1 + attributes.Length, element.ElementsAndAttributes().Count());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:8,代码来源:HtmlElement.ReplaceTests.cs

示例5: ReplaceAttributes_ParamsHtmlAttribute_VoidElement

        public void ReplaceAttributes_ParamsHtmlAttribute_VoidElement()
        {
            HtmlElement parent = new HtmlElement("parent", isVoid: true);
            parent.Add(new HtmlAttribute("attribute"));

            HtmlAttribute[] attributes = new HtmlAttribute[] { new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2") };
            parent.ReplaceAttributes(attributes);
            Assert.Equal(attributes, parent.Attributes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElement.ReplaceTests.cs

示例6: ReplaceAttributes_ParamsHtmlAttribute

 public void ReplaceAttributes_ParamsHtmlAttribute(HtmlAttribute[] attributes)
 {
     HtmlElement parent = new HtmlElement("parent", new HtmlElement("element"), new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2"));
     parent.ReplaceAttributes(attributes);
     Assert.Equal(1, parent.Elements().Count());
     Assert.Equal(attributes, parent.Attributes().ToArray());
     Assert.Equal(1 + attributes.Length, parent.ElementsAndAttributes().Count());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:8,代码来源:HtmlElement.ReplaceTests.cs


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