本文整理汇总了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 }));
}
示例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 }));
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}