本文整理汇总了C#中HtmlTags.HtmlTag.TagName方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.TagName方法的具体用法?C# HtmlTag.TagName怎么用?C# HtmlTag.TagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTags.HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.TagName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public void Visit(HtmlTag table)
{
if (table.TagName().ToLower() != HtmlTagConstants.Table)
{
throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Table,
table.TagName()));
}
table.Children.ForEach(VisitTableChild);
}
示例2: VisitImage
public ExportImage VisitImage(HtmlTag imageTag)
{
if (imageTag.TagName().ToLower() != HtmlTagConstants.Img)
{
throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Img,
imageTag.TagName()));
}
var image = (ImageTag) imageTag;
return new ExportImage {Source = image.Src(), AlternateText = image.Alt()};
}
示例3: VisitList
public ExportList VisitList(HtmlTag list )
{
if(list.TagName().ToLower() != HtmlTagConstants.Ul )
{
throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Ul,
list.TagName()));
}
var exportList = new ExportList();
list.Children.ForEach(f => VisitListItem(f, exportList));
return exportList;
}
示例4: AssertOptionGroup
private void AssertOptionGroup(
HtmlTag optgroup,
string display)
{
Assert.Equal("optgroup", optgroup.TagName());
Assert.Equal(display, optgroup.Attr("label"));
}
示例5: do_nothing_to_a_link_that_is_authorized
public void do_nothing_to_a_link_that_is_authorized()
{
var tag = new HtmlTag("a").Authorized(true)
.ReadOnlyIfNotAuthorized();
tag.Authorized().ShouldBeTrue();
tag.TagName().ShouldEqual("a");
}
示例6: do_nothing_to_a_div
public void do_nothing_to_a_div()
{
var tag = new HtmlTag("div").Authorized(false)
.ReadOnlyIfNotAuthorized();
tag.Authorized().ShouldBeFalse();
tag.TagName().ShouldEqual("div");
}
示例7: change_an_unauthorized_link_to_a_span_and_authorize_the_span
public void change_an_unauthorized_link_to_a_span_and_authorize_the_span()
{
var tag = new HtmlTag("a").Authorized(false)
.ReadOnlyIfNotAuthorized();
tag.Authorized().ShouldBeTrue();
tag.TagName().ShouldEqual("span");
}
示例8: AssertOption
private void AssertOption(
HtmlTag option,
string display,
object value)
{
Assert.Equal("option", option.TagName());
Assert.Equal(display, option.Text());
Assert.True(option.ValueIsEqual(value));
}
示例9: VisitListItem
public void VisitListItem(HtmlTag list, ExportListItem exportList)
{
var item = new ExportListItem();
if(list.TagName().ToLower() == HtmlTagConstants.Ul)
{
item = new ExportList();
}
list.Children.ForEach(f => VisitListItem(f, item));
item.Text = ExportFromTable.HtmlTagRegex.Replace(list.Text(), String.Empty);
exportList.AddItem(item);
}
示例10: AssertValid
public void AssertValid(HtmlTag tag, string tagName, string name, string type = "", object value = null)
{
Assert.Equal(tagName, tag.TagName());
Assert.Equal(name, tag.Attr("name"));
Assert.Equal(name, tag.Attr("id"));
if (type == null)
Assert.False(tag.HasAttr("type"));
else
Assert.Equal(type, tag.Attr("type"));
if (value == null)
Assert.True(!tag.HasAttr("value") || tag.Attr("value") == "");
else
Assert.Equal(value.ToString(), tag.Attr("value"));
}
示例11: ChildTagBuilder
public ChildTagBuilder(SpecHierarchyBuilder builder, HtmlTag parent)
{
if (parent.TagName() != "ul")
{
throw new ArgumentOutOfRangeException("Only ul tags are valid here: \n" + parent.ToString());
}
_builder = builder;
_parent = parent;
}
示例12: TopTag
public HtmlTag TopTag(HtmlTag topChild)
{
if (topChild.TagName() != "ul")
{
throw new ArgumentOutOfRangeException("Only ul tags are valid here: \n" + topChild.ToString());
}
var topUrl = _urls.UrlFor<JasminePages>(x => x.AllSpecs());
return new HtmlTag("ul", tag =>
{
tag.Id("all-specs-node").AddClass("filetree");
var link = new LinkTag("All Specs", topUrl, "all-specs");
var li = tag.Add("li");
li.Add("span").AddClass("folder").Append(link);
li.Append(topChild);
});
}
示例13: VisitTableChild
private void VisitTableChild(HtmlTag child)
{
var tag = child.TagName().ToLower();
switch (tag)
{
case HtmlTagConstants.Tr:
VisitTableRow(child);
break;
case HtmlTagConstants.Caption:
VisitCaption(child);
break;
default:
child.Children.ForEach(VisitTableChild);
break;
}
}
示例14: VisitTableCell
private static void VisitTableCell(HtmlTag cell, ExportRow exportRow)
{
var tag = cell.TagName().ToLower();
if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th )
{
cell.Children.ForEach(c => VisitTableCell(c, exportRow));
return;
}
var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img);
var text = cell.Children.Any() ? cell.ToString() : cell.Text();
var exportCell = new ExportCell
{
Text = ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty),
Markup = isImage ? cell.FirstChild().ToString():string.Empty
};
SetColspan(cell, exportCell);
exportRow.AddCell(exportCell);
}