private static IHtmlContent CreateTableHtmlIpsum <T>(IList <T> data, object tableAttributes) where T : new() { TagBuilder table = new TagBuilder("table"); table.InnerHtml.SetHtmlContent(BuildTableHeader <T>()); TagBuilder tbody = new TagBuilder("tbody"); foreach (var item in data) { TagBuilder tr = new TagBuilder("tr"); foreach (var property in typeof(T).GetProperties()) { TagBuilder td = new TagBuilder("td"); td.InnerHtml.SetContent(property.GetValue(item).ToString()); tr.InnerHtml.AppendHtml(td); } tbody.InnerHtml.AppendHtml(tr); } table.MergeAttributes(HtmlAttributeHelper.GetHtmlAttributeDictionaryOrNull(tableAttributes)); //table.MergeAttribute("class", "", false); table.InnerHtml.AppendHtml(tbody); return(table); }
public static WireframeGenerator Image(this WireframeGenerator gen, int width, int height, string text = null, string backgroundColor = null, string textColor = null, object htmlAttributes = null, ImgFormat format = ImgFormat.GIF) { var img = new TagBuilder("img"); img.TagRenderMode = TagRenderMode.SelfClosing; img.Attributes.Add("src", PlaceholditUrlBuilder.UrlFor(width, height, text, backgroundColor, textColor)); img.MergeAttributes(HtmlAttributeHelper.GetHtmlAttributeDictionaryOrNull(htmlAttributes)); return(gen.Add(img)); }
private static IHtmlContent GenerateListHtmlIpsum(string outer, string inner, int listCount, bool links, object liAttributes, int wordCount, object ulAttributes) { TagBuilder element = new TagBuilder(outer); for (int i = 0; i < listCount; i++) { if (links) { TagBuilder li = new TagBuilder(inner); li.MergeAttributes(HtmlAttributeHelper.GetHtmlAttributeDictionaryOrNull(liAttributes)); li.InnerHtml.SetHtmlContent(WireframeGenerator.GenerateHtmlIpsum("a", () => Lorem.GenerateWords(wordCount), HtmlAttributeHelper.GetHtmlAttributeDictionaryOrNull(new { href = "#" }))); element.InnerHtml.AppendHtml(li); } else { element.InnerHtml.AppendHtml(WireframeGenerator.GenerateHtmlIpsum(inner, () => Lorem.GenerateWords(wordCount), liAttributes)); } } element.MergeAttributes(HtmlAttributeHelper.GetHtmlAttributeDictionaryOrNull(ulAttributes)); return(element); }