本文整理汇总了C#中HtmlElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlElement.GetType方法的具体用法?C# HtmlElement.GetType怎么用?C# HtmlElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyElement
private static void VerifyElement(HtmlElement element, string tag, bool isVoid, params string[] attributeNames)
{
Assert.Equal(tag, element.Tag);
Assert.Equal(isVoid, element.IsVoid);
Assert.Null(element.Parent);
foreach (string attributeName in attributeNames)
{
bool attributeIsVoid = typeof(Attribute).GetMethod(attributeName) == null;
MethodInfo method = element.GetType().GetMethod("With" + attributeName);
if (attributeIsVoid)
{
HtmlAttribute expectedAttribute = (HtmlAttribute)typeof(Attribute).GetProperty(attributeName).GetValue(null);
Assert.Empty(method.GetParameters());
Assert.Same(element, method.Invoke(element, new object[0]));
HtmlAttribute actualAttribute;
Assert.True(element.TryGetAttribute(expectedAttribute.Name, out actualAttribute));
Assert.Equal(expectedAttribute, actualAttribute);
}
else
{
HtmlAttribute expectedAttribute = (HtmlAttribute)typeof(Attribute).GetMethod(attributeName).Invoke(null, new object[] { "value" });
Assert.Equal(new Type[] { typeof(string) }, method.GetParameters().Select(parameter => parameter.ParameterType));
Assert.Same(element, method.Invoke(element, new object[] { "value" }));
HtmlAttribute actualAttribute;
Assert.True(element.TryGetAttribute(expectedAttribute.Name, out actualAttribute));
Assert.Equal(expectedAttribute, actualAttribute);
}
}
}