public static void RenderNewsResults(HtmlWriter writer, SearchResult result, Pager pager) { var subjects = DataService.Instance.GetSubjects(); foreach (var record in result.Records.OrderByDescending(r => r.GetDate("date")).Skip(pager.Skip).Take(pager.Take)) { writer.RenderBeginTag(HtmlTextWriterTag.H3); writer.RenderLinkTag(record.GetString("url"), record.GetString("title")); writer.RenderEndTag(); writer.RenderFullTag(HtmlTextWriterTag.H6, "Publiseret " + record.GetDate("date").Value.ToString("dd-MM-yyyy")); var subjectList = record.GetString("subjects"); if (!string.IsNullOrEmpty(subjectList)) { foreach (var subjectId in subjectList.Split(',').Select(s => new Id(s.Trim())).Where(subjects.ContainsKey)) { writer.RenderFullTag(HtmlTextWriterTag.Span, subjects[subjectId], "label"); } } string text = record.GetString("summary"); if (text.Length > 150) text = text.Substring(0, 150); writer.RenderFullTag(HtmlTextWriterTag.P, text); } }
private static void GenerateOutput(HtmlWriter writer) { var page = CmsService.Instance.GetItem<UmbracoPublic.Logic.Entities.NewsPage>(); if (!string.IsNullOrEmpty(page.Headline)) writer.RenderFullTag(HtmlTextWriterTag.H1, page.Headline); if (page.Date.HasValue) writer.RenderFullTag(HtmlTextWriterTag.H6, string.Format("Publiseret {0}", page.Date.Value.ToString("dd-MM-yyyy"))); foreach (var categorization in page.Categorizations) writer.RenderFullTag(HtmlTextWriterTag.Span, categorization, "label"); if (!page.Intro.IsEmpty) writer.RenderParagraph(page.Intro.AsHtml); var linkedDocument = page.LinkedDocument; if (linkedDocument.Exists) { writer.RenderBeginTag(HtmlTextWriterTag.Div, "linked-document"); writer.RenderBeginTag(HtmlTextWriterTag.Ul, "thumbnails"); writer.RenderBeginTag(HtmlTextWriterTag.Li, "span4"); writer.RenderBeginTag(HtmlTextWriterTag.Div, "thumbnail"); writer.RenderImageTag(page.Thumbnail.Url, null, null); writer.RenderBeginTag(HtmlTextWriterTag.P); writer.RenderLinkTag(page.LinkedDocument.Url, "Åbn publikation", "btn btn-primary"); writer.RenderEndTag(); // p writer.RenderEndTag(); // div.thumbnail writer.RenderEndTag(); // li.span4 writer.RenderEndTag(); // ul.thumbnails writer.RenderEndTag(); } if (!page.Body.IsEmpty) writer.Write(page.Body.ToString()); }
public static void RenderContact(HtmlWriter writer, ContactModule module, bool showHeader) { writer.RenderBeginTag(HtmlTextWriterTag.Div, "thumbnail contact"); if (showHeader) writer.RenderFullTag(HtmlTextWriterTag.H3, "Kontakt"); writer.AddAttribute(HtmlTextWriterAttribute.Src, module.Image.Url); writer.AddAttribute(HtmlTextWriterAttribute.Alt, module.FullName); writer.RenderImageTag(module.Image.Url, module.FullName, null); writer.RenderBeginTag(HtmlTextWriterTag.Div, "caption"); writer.RenderBeginTag(HtmlTextWriterTag.H5); writer.Write(module.FullName); writer.RenderEndTag(); // h5 writer.RenderBeginTag(HtmlTextWriterTag.P); WriteContactInfo(writer, module.Title); WriteContactInfo(writer, module.Area); if (!string.IsNullOrEmpty(module.Email)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, "Email : " + module.Email); writer.RenderLinkTag("mailto:" + module.Email, "Email : " + module.Email); writer.WriteBreak(); } WriteContactInfo(writer, module.Phone, "Tlf."); WriteContactInfo(writer, module.Mobile, "Mobil"); writer.RenderEndTag(); // p writer.RenderEndTag(); // div.caption writer.RenderEndTag(); // div.thumbnail.contact }
private void RenderOutput(HtmlWriter writer) { writer.RenderBeginTag(HtmlTextWriterTag.Div, "well facts"); if (!string.IsNullOrEmpty(Headline)) writer.RenderFullTag(HtmlTextWriterTag.H3, Headline); var html = new Html(System.Web.HttpUtility.UrlDecode(Content)); writer.RenderRichText(html); writer.RenderEndTag(); }
public override void Write(object o, HtmlWriter tag, DumpState state, RefDictionary refDict) { var val = o.ToString(); tag.Tag("kbd", t => { t.NewLineAfterSTag = false; t.WriteString(val); }); }
private static void GenerateOutput(HtmlWriter writer) { var page = CmsService.Instance.GetItem<UmbracoPublic.Logic.Entities.WebPage>(); if (!string.IsNullOrEmpty(page.Headline)) writer.RenderFullTag(HtmlTextWriterTag.H1, page.Headline); if (!page.Intro.IsEmpty) writer.RenderFullTag(HtmlTextWriterTag.H4, page.Intro.AsHtml, "intro"); if (!page.Body.IsEmpty) writer.Write(page.Body.ToString()); }
protected override void Render(HtmlTextWriter w) { var writer = new HtmlWriter(w); writer.AddClass("alert"); if (!string.IsNullOrEmpty(this.Type)) writer.AddClass(this.Type); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute("data-dismiss", "alert"); writer.RenderFullTag(HtmlTextWriterTag.Button, "×", "close"); writer.Write(HttpUtility.UrlDecode(Text)); writer.RenderEndTag(); // div.alert }
private static void GenerateOutput(HtmlWriter writer, SearchService service) { writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var record in service.GetAllRecords().OrderBy(r => r.Id)) { var id = record.Id; writer.RenderBeginTag(HtmlTextWriterTag.Li); var href = "/test/IndexDetails.aspx?id=" + HttpUtility.UrlEncode(id); writer.RenderLinkTag(href, id); writer.RenderEndTag(); } writer.RenderEndTag(); }
public static void RenderCategorizations(HtmlWriter writer, IEnumerable<Id> categorizations, Dictionary<Id, Categorization> visibleCategorizations, string newsListUrl = null) { if (newsListUrl == null) newsListUrl = Urls.GetMainNewsListUrl(); foreach (var categorizationId in categorizations) { if (!visibleCategorizations.ContainsKey(categorizationId)) continue; writer.RenderLinkTag(newsListUrl + "?categorizations=" + categorizationId, visibleCategorizations[categorizationId].DisplayName, "label"); } }
private static void GenerateOutput(HtmlWriter writer) { var page = CmsService.Instance.GetItem<UmbracoPublic.Logic.Entities.NewsPage>(); if (!string.IsNullOrEmpty(page.Headline)) writer.RenderFullTag(HtmlTextWriterTag.H1, page.Headline); if (page.Date.HasValue) writer.RenderFullTag(HtmlTextWriterTag.H6, string.Format("Publiseret {0}", page.Date.Value.ToString("dd-MM-yyyy"))); foreach (var subject in page.Subjects) writer.RenderFullTag(HtmlTextWriterTag.Span, subject, "label"); if (!page.Intro.IsEmpty) writer.RenderParagraph(page.Intro.AsHtml); if (!page.Body.IsEmpty) writer.Write(page.Body.ToString()); }
public static void RenderNewsResults(HtmlWriter writer, SearchRecord[] records, bool renderUl = true) { var visibleCategorizations = CategorizationFolder.GetVisibleCategorizations(); var newsListUrl = Urls.GetMainNewsListUrl(); if (renderUl) writer.RenderBeginTag(HtmlTextWriterTag.Ul, "news-items"); foreach (var record in records) { var date = record.GetDate("date"); if (date == null) continue; writer.RenderBeginTag(HtmlTextWriterTag.Li, "clearfix"); if (!string.IsNullOrEmpty(record.GetString("thumbnail"))) { writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderImageTag(record.GetString("thumbnail"), record.GetString("title"), null); writer.RenderEndTag(); // div } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Href, record.GetString("url")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderFullTag(HtmlTextWriterTag.H3, record.GetString("title")); writer.RenderEndTag(); // a writer.RenderFullTag(HtmlTextWriterTag.Span, "Publiseret " + record.GetDate("date").Value.ToString("dd-MM-yyyy"), "date"); var categorizations = new IdList(record.GetString("categorizations")); if (categorizations.Any()) { RenderCategorizations(writer, categorizations, visibleCategorizations, newsListUrl); } writer.RenderBeginTag(HtmlTextWriterTag.A); var text = record.GetString("summary"); if (text.Length > 150) text = text.Substring(0, 150); writer.RenderFullTag(HtmlTextWriterTag.P, text); writer.RenderEndTag(); // a writer.RenderEndTag(); // div writer.RenderEndTag(); // li.clearfix } if (renderUl) writer.RenderEndTag(); }
public string ToHtmlString() { IHtmlWriter htmlWriter = new HtmlWriter(); this.SetupDataBind(htmlWriter); if (null != this.field.Widget && !String.IsNullOrEmpty(this.field.Widget.Width)) htmlWriter.Prop("style", "width:" + this.field.Widget.Width); //ReadOnly jQuery 1.6+ if (this.field.ReadOnly) htmlWriter.Prop("disabled", true); //setUpValidation htmlWriter .Prop("data-val", "true"); if (!this.field.IsNullable) { htmlWriter .Prop("required", "true") .Prop("data-val-required", "Bu Alan Boş Geçilemez.") .Prop("data-required-required", "Bu Alan Boş Geçilemez."); } // htmlWriter.AppendExtendedHtml(this.field);//tag lenmeden önce this.WriteHtml(htmlWriter, this.field); string html = htmlWriter.ToString(); string script = ""; IHtmlWriter scriptWriter = new HtmlWriter(); this.WriteScript(scriptWriter, this.field); if (scriptWriter.Length > 0) { IHtmlWriter scriptWriterFinal = new HtmlWriter(); scriptWriterFinal .Append("jQuery(function(){") .Append(scriptWriter) .Append("});") .Tag("script", TagTypes.Paired); script = scriptWriterFinal.ToString(); } return html + script; }
protected void RenderPageLink(HtmlWriter writer, int? pageLink, string text, string cssClass, bool addSpan) { writer.AddClass(cssClass); writer.RenderBeginTag(HtmlTextWriterTag.Li); if (pageLink.HasValue) { writer.AddAttribute(HtmlTextWriterAttribute.Title, text); writer.RenderBeginLink(Urls.ReplaceUrlParameter(QueryStringKey.PageNumber, pageLink.Value.ToString())); } else writer.RenderBeginLink("#"); if (addSpan) writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(text); if (addSpan) writer.RenderEndTag(); writer.RenderEndTag(); // a or strong writer.RenderEndTag(); // li }
public async Task RenderPage(RedwoodRequestContext context, Page page, string serializedViewModel) { // set up integration scripts //var integrationScripts = page.OfType<IntegrationScripts>().Single(); //integrationScripts.SerializedViewModel = serializedViewModel; //integrationScripts.InternalScriptUrls = new List<string>() { // context.OwinContext.Request.PathBase + "/Scripts/knockout-3.0.0.js", // context.OwinContext.Request.PathBase + "/Scripts/knockout.mapping-latest.js", // context.OwinContext.Request.PathBase + "/Scripts/knockout.validation.js", // context.OwinContext.Request.PathBase + "/Scripts/Redwood.js", // context.OwinContext.Request.PathBase + "/Data.js" //}; // get the HTML var writer = new HtmlWriter(); page.Render(writer); var html = writer.ToString(); // return the response context.OwinContext.Response.ContentType = "text/html; charset=utf-8"; await context.OwinContext.Response.WriteAsync(html); }
public override void Render(HtmlWriter writer, int pageNumber, int firstPage, int lastPage, int pages, bool showEnds, bool renderOuterTag) { if (renderOuterTag) writer.RenderBeginTag(HtmlTextWriterTag.Div, "pagination"); writer.RenderBeginTag(HtmlTextWriterTag.Ul); if (pageNumber > 1) RenderPageLink(writer, pageNumber - 1, "Prev", "prev", true); else RenderPageLink(writer, null, "Prev", "prev disabled", true); for (var i = firstPage; i <= lastPage; i++) RenderPageLink(writer, i == pageNumber ? (int?)null : i, i.ToString(), i == pageNumber ? "page disabled" : "page", true); if (pageNumber < pages) RenderPageLink(writer, pageNumber + 1, "Next", "next", true); else RenderPageLink(writer, null, "Next", "next disabled", true); writer.RenderEndTag(); // ul if (renderOuterTag) writer.RenderEndTag(); // div.pagination }
protected override void Build() { HtmlWriter.Write(ApplicationInfo.Version); }
public override void Render(HtmlWriter writer, int pageNumber, int firstPage, int lastPage, int pages, bool showEnds, bool renderOuterTag) { throw new NotImplementedException(); }
public abstract void Render(HtmlWriter writer, int pageNumber, int firstPage, int lastPage, int pages, bool showEnds, bool renderOuterTag);
protected override void Build() { var networks = NetworkInterface.GetAllNetworkInterfaces().ToList().OrderBy(@interface => @interface.OperationalStatus); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>Network Interfaces</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "#"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Device ID"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Name / Description"); //HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Description"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Properties"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Statistics"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, HtmlTextWriterAttribute.Class, "text-center", "Status"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); var i = 0; foreach (var adapter in networks) { var properties = adapter.GetIPProperties(); var statistics = adapter.GetIPv4Statistics(); i++; HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "index", i.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "deviceid", string.Format("{0}<br>" + "MAC Address: {1}<br>Type: {2}", adapter.Id, string.Join(":", adapter.GetPhysicalAddress().GetAddressBytes().Select(b => b.ToString("X2"))), adapter.NetworkInterfaceType)); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "name", string.Format("<strong>Name:</strong> {0}<br><strong>Description:</strong> {1}", adapter.Name, adapter.Description)); //HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "description", adapter.Description); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "properties"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "Unicast Addresses:"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Ol); foreach (var address in properties.UnicastAddresses) { HtmlWriter.RenderTag(HtmlTextWriterTag.Li, address.Address.ToString()); } HtmlWriter.RenderEndTag(); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "DHCP Server Addresses:"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Ol); foreach (var address in properties.DhcpServerAddresses) { HtmlWriter.RenderTag(HtmlTextWriterTag.Li, address.ToString()); } HtmlWriter.RenderEndTag(); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "Gateway Addresses:"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Ol); foreach (var address in properties.GatewayAddresses) { HtmlWriter.RenderTag(HtmlTextWriterTag.Li, address.Address.ToString()); } HtmlWriter.RenderEndTag(); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "DNS Addresses:"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Ol); foreach (var address in properties.DnsAddresses) { HtmlWriter.RenderTag(HtmlTextWriterTag.Li, address.ToString()); } HtmlWriter.RenderEndTag(); HtmlWriter.RenderEndTag(); // </td> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "Megabytes Received:"); HtmlWriter.Write(" {0} MB<br>", (statistics.BytesReceived / 1024 / 1024)); HtmlWriter.RenderTag(HtmlTextWriterTag.Strong, "Megabytes Sent:"); HtmlWriter.Write(" {0} MB<br>", (statistics.BytesSent / 1024 / 1024)); HtmlWriter.RenderEndTag(); // </td> HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "status text-center"); switch (adapter.OperationalStatus) { case OperationalStatus.Up: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-success"); break; case OperationalStatus.Down: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-danger"); break; default: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-warning"); break; } HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(adapter.OperationalStatus); HtmlWriter.RenderEndTag(); // </td> HtmlWriter.RenderEndTag(); // </tr> } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); /* * Global Statistics */ try { var ipv4GlobalStatistics = ipGlobalProperties.GetIPv4GlobalStatistics(); var ipv6GlobalStatistics = ipGlobalProperties.GetIPv6GlobalStatistics(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>Global Statistics</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Statistic Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "IPv4 Value"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "IPv6 Value"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); foreach (var prop in ipv4GlobalStatistics.GetType().GetProperties()) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "name", prop.Name.SpaceCamelCase()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "ipv4value", prop.GetValue(ipv4GlobalStatistics).ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "ipv6value", prop.GetValue(ipv6GlobalStatistics).ToString()); HtmlWriter.RenderEndTag(); } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> } catch { // ignored } //HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "row"); //HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); //HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-sm-6"); //HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); /* * ICMP Statistics */ try { var icmpv4Statistics = ipGlobalProperties.GetIcmpV4Statistics(); var icmpv4StatisticsProps = ipGlobalProperties.GetIcmpV4Statistics().GetType().GetProperties(); var icmpv6Statistics = ipGlobalProperties.GetIcmpV6Statistics(); var icmpv6StatisticsProps = ipGlobalProperties.GetIcmpV6Statistics().GetType().GetProperties(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>ICMP Statistics</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "ICMPv4 Statistic Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "ICMPv4 Value"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "ICMPv6 Statistic Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "ICMPv6 Value"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); for (var x = 0; x < Math.Max(icmpv4StatisticsProps.Length, icmpv6StatisticsProps.Length); x++) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); if (x < icmpv4StatisticsProps.Length) { HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv4name", icmpv4StatisticsProps[x].Name.SpaceCamelCase()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv4value", icmpv4StatisticsProps[x].GetValue(icmpv4Statistics).ToString()); } else { HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv4name", string.Empty); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv4value", string.Empty); } if (x < icmpv6StatisticsProps.Length) { HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv6name", icmpv6StatisticsProps[x].Name.SpaceCamelCase()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv6value", icmpv6StatisticsProps[x].GetValue(icmpv6Statistics).ToString()); } else { HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv6name", string.Empty); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "icmpv6value", string.Empty); } HtmlWriter.RenderEndTag(); } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> } catch { // ignored } try { /* * TCP Statistics */ var ipv4Statistics = ipGlobalProperties.GetTcpIPv4Statistics(); var ipv6Statistics = ipGlobalProperties.GetTcpIPv6Statistics(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>TCP Statistics</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Statistic Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "TCPv4 Value"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "TCPv6 Value"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); foreach (var prop in ipv4Statistics.GetType().GetProperties()) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "name", prop.Name.SpaceCamelCase()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "tcp4value", prop.GetValue(ipv4Statistics).ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "tcpv6value", prop.GetValue(ipv6Statistics).ToString()); HtmlWriter.RenderEndTag(); } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> } catch { // ignored } try { /* * UDP Statistics */ var udp4Statistics = ipGlobalProperties.GetUdpIPv4Statistics(); var udp6Statistics = ipGlobalProperties.GetUdpIPv6Statistics(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>UDP Statistics</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Statistic Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "UDPv4 Value"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "UDPv6 Value"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); foreach (var prop in udp4Statistics.GetType().GetProperties()) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "name", prop.Name.SpaceCamelCase()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "udp4value", prop.GetValue(udp4Statistics).ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "udpv6value", prop.GetValue(udp6Statistics).ToString()); HtmlWriter.RenderEndTag(); } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> } catch { // ignored } HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderTag(HtmlTextWriterTag.Caption, HtmlTextWriterAttribute.Class, "text-center", "<h2>TCP and UDP Connections</h2>"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Protocol"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Local Address"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Local Port"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Remote Address"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Remote Port"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "State"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); try { /** * Active TCP Connections */ var activeTcpConnections = ipGlobalProperties.GetActiveTcpConnections(); foreach (var con in activeTcpConnections) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "protocol", con.LocalEndPoint.Address.ToString().Contains("::") ? "TCPv6" : "TCP"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localip", con.LocalEndPoint.Address.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localport", con.LocalEndPoint.Port.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteip", con.RemoteEndPoint.Address.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteport", con.RemoteEndPoint.Port.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "State", con.State.ToString()); HtmlWriter.RenderEndTag(); } } catch { // ignored } try { /** * Active TCP Listeners */ var activeTcpListeners = ipGlobalProperties.GetActiveTcpListeners(); foreach (var con in activeTcpListeners) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "protocol", con.Address.ToString().Contains(":") ? "TCPv6" : "TCP"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localip", con.Address.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localport", con.Port.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteip", con.Address.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteport", "0"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "State", "Listening"); HtmlWriter.RenderEndTag(); } } catch { // ignored } try { /** * Active UDP Listeners */ var activeUdpListeners = ipGlobalProperties.GetActiveUdpListeners(); foreach (var con in activeUdpListeners) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "protocol", con.Address.ToString().Contains(":") ? "UDPv6" : "UDP"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localip", con.Address.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "localport", con.Port.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteip", "*"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "remoteport", "*"); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "State", "Listening"); HtmlWriter.RenderEndTag(); } } catch { // ignored } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> }
private static void RenderState(ref bool isDone, HtmlWriter w) { if (Instance == null) return; w.RenderBeginTag(HtmlTextWriterTag.Table); foreach (var task in Instance.Tasks) { w.RenderBeginTag(HtmlTextWriterTag.Tr); w.RenderBeginTag(HtmlTextWriterTag.Td, "title"); w.RenderFullTag(HtmlTextWriterTag.Span, task.Name); w.RenderEndTag(); w.RenderBeginTag(HtmlTextWriterTag.Td, "progress"); if (!string.IsNullOrEmpty(task.Error)) { w.RenderFullTag(HtmlTextWriterTag.Span, "Error", "processing"); } else if (task.IsProcessing) { var progress = "Processing"; if (task.CanDeterminePercentage) progress += " " + task.PercentDone + "%"; w.RenderFullTag(HtmlTextWriterTag.Span, progress, "processing"); isDone = false; } else if (task.Done) { w.RenderFullTag(HtmlTextWriterTag.Span, "Done", "done"); } else { w.Write(" "); isDone = false; } w.RenderEndTag(); w.RenderEndTag(); // tr } w.RenderEndTag(); }
public string ToHtmlString() { var writer = new HtmlWriter() .Prop("type", "checkbox") .Prop("id", this.propertyName) .Prop("name", this.propertyName) .Prop("data-bind", "checked:" + this.field.PropertyName); if (this.field.ReadOnly) { writer.Prop("disabled", "true"); } //setUpValidation writer.Prop("data-val", "true"); if (!this.field.IsNullable) { writer .Prop("required", "true") .Prop("data-val-required", "Bu Alan Boş Geçilemez.") .Prop("data-required-required", "Bu Alan Boş Geçilemez."); } // writer.AppendExtendedHtml(this.field);//tag lenmeden önce return writer.Tag("input", TagTypes.Unpaired).ToString(); }
protected override void Build() { HtmlWriter.Write("{0} - {1}", Environment.MachineName, DateTime.Now.ToString(CultureInfo.CurrentCulture)); }
private static void RenderDropDown(HtmlWriter writer, IEnumerable<GridCell> cells, GridCell selectedCell, IEnumerable<int> validOptions) { writer.RenderBeginTag(HtmlTextWriterTag.Select); writer.AddAttribute("value", ""); if (selectedCell == null) writer.AddAttribute("selected","selected"); writer.RenderFullTag(HtmlTextWriterTag.Option, "None"); foreach (var cell in cells.Where(c => c.ColumnSpan >= validOptions.Min())) { writer.AddAttribute(HtmlTextWriterAttribute.Value, cell.Key); if (cell == selectedCell) writer.AddAttribute("selected", "selected"); writer.RenderFullTag(HtmlTextWriterTag.Option, cell.Key); } writer.RenderEndTag(); }
// Replaces <img src=...> urls that refer to images embedded within the message with // "file://" urls that the browser control will actually be able to load. void HtmlTagCallback(HtmlTagContext ctx, HtmlWriter htmlWriter) { if (ctx.TagId == HtmlTagId.Image && !ctx.IsEndTag && stack.Count > 0) { ctx.WriteTag(htmlWriter, false); // replace the src attribute with a file:// URL foreach (var attribute in ctx.Attributes) { if (attribute.Id == HtmlAttributeId.Src) { MimePart image; string url; if (!TryGetImage(attribute.Value, out image)) { htmlWriter.WriteAttribute(attribute); continue; } url = SaveImage(image, attribute.Value); htmlWriter.WriteAttributeName(attribute.Name); htmlWriter.WriteAttributeValue(url); } else { htmlWriter.WriteAttribute(attribute); } } } else if (ctx.TagId == HtmlTagId.Body && !ctx.IsEndTag) { ctx.WriteTag(htmlWriter, false); // add and/or replace oncontextmenu="return false;" foreach (var attribute in ctx.Attributes) { if (attribute.Name.ToLowerInvariant() == "oncontextmenu") { continue; } htmlWriter.WriteAttribute(attribute); } htmlWriter.WriteAttribute("oncontextmenu", "return false;"); } else if (ctx.TagId == HtmlTagId.A && !ctx.IsEndTag) { ctx.WriteTag(htmlWriter, false); // add and/or replace target="_blank" foreach (var attribute in ctx.Attributes) { if (attribute.Name.ToLowerInvariant() == "target") { continue; } htmlWriter.WriteAttribute(attribute); } htmlWriter.WriteAttribute("target", "_blank"); } else { // pass the tag through to the output ctx.WriteTag(htmlWriter, true); } }
// Replaces <img src=...> urls that refer to images embedded within the message with // "file://" urls that the browser control will actually be able to load. void HtmlTagCallback(HtmlTagContext ctx, HtmlWriter htmlWriter) { if (ctx.TagId == HtmlTagId.Meta && !ctx.IsEndTag) { bool isContentType = false; ctx.WriteTag(htmlWriter, false); // replace charsets with "utf-8" since our output will be in utf-8 (and not whatever the original charset was) foreach (var attribute in ctx.Attributes) { if (attribute.Id == HtmlAttributeId.Charset) { htmlWriter.WriteAttributeName(attribute.Name); htmlWriter.WriteAttributeValue("utf-8"); } else if (isContentType && attribute.Id == HtmlAttributeId.Content) { htmlWriter.WriteAttributeName(attribute.Name); htmlWriter.WriteAttributeValue("text/html; charset=utf-8"); } else { if (attribute.Id == HtmlAttributeId.HttpEquiv && attribute.Value != null && attribute.Value.Equals("Content-Type", StringComparison.OrdinalIgnoreCase)) { isContentType = true; } htmlWriter.WriteAttribute(attribute); } } } else if (ctx.TagId == HtmlTagId.Image && !ctx.IsEndTag && stack.Count > 0) { ctx.WriteTag(htmlWriter, false); // replace the src attribute with a "data:" URL foreach (var attribute in ctx.Attributes) { if (attribute.Id == HtmlAttributeId.Src) { if (!TryGetImage(attribute.Value, out var image)) { htmlWriter.WriteAttribute(attribute); continue; } var dataUri = GetDataUri(image); htmlWriter.WriteAttributeName(attribute.Name); htmlWriter.WriteAttributeValue(dataUri); } else { htmlWriter.WriteAttribute(attribute); } } } else if (ctx.TagId == HtmlTagId.Body && !ctx.IsEndTag) { ctx.WriteTag(htmlWriter, false); // add and/or replace oncontextmenu="return false;" foreach (var attribute in ctx.Attributes) { if (attribute.Name.Equals("oncontextmenu", StringComparison.OrdinalIgnoreCase)) { continue; } htmlWriter.WriteAttribute(attribute); } htmlWriter.WriteAttribute("oncontextmenu", "return false;"); } else { // pass the tag through to the output ctx.WriteTag(htmlWriter, true); } }
protected override void Build() { var i = 0; foreach (var specialFile in Managers.SpecialFileManager) { i++; HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "panel panel-success"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "panel-heading"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.H2); HtmlWriter.RenderTag(HtmlTextWriterTag.Div, HtmlTextWriterAttribute.Class, "pull-right", string.Format("<span class=\"badge\" style=\"font-size:34px;\">{0}</span>", i)); HtmlWriter.Write("<i class=\"fa fa-file-o\"></i> {0}", specialFile.Filename); HtmlWriter.RenderEndTag(); // </h2> HtmlWriter.RenderTag(HtmlTextWriterTag.Span, specialFile.FullPath); HtmlWriter.RenderEndTag(); // </div> HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "panel-body"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); HtmlWriter.RenderTag(HtmlTextWriterTag.Pre, specialFile.Content.ToString()); HtmlWriter.RenderEndTag(); // </div> HtmlWriter.RenderEndTag(); // </div> } /*HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); * HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); * * HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); * HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); * * HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "#"); * HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Program"); * HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Version"); * HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Publisher"); * HtmlWriter.RenderTag(HtmlTextWriterTag.Th, SystemHelper.IsWindows ? "Install Date" : "Description"); * * HtmlWriter.RenderEndTag(); // </tr> * HtmlWriter.RenderEndTag(); // </thead> * * HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); * * foreach (var program in programManager) * { * i++; * if (MalwareManager.Instance.Contains(program.Name)) * { * HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "danger"); * } * else if (program.Name.Contains("toolbar", StringComparison.OrdinalIgnoreCase)) * { * HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "warning"); * } * * HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); * * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "index", i.ToString()); * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "program", program.Name); * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "version", program.Version); * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "publisher", program.Publisher); * * if(SystemHelper.IsWindows) * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "installdate", program.InstallDate); * else * HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "description", program.Description); * * HtmlWriter.RenderEndTag(); * * } * * HtmlWriter.RenderEndTag(); // </tbody> * HtmlWriter.RenderEndTag(); // </table>*/ }
// Token: 0x06001409 RID: 5129 RVA: 0x00073CB4 File Offset: 0x00071EB4 public Stream GetData(BodyType type, long truncationSize, out long totalDataSize, out IEnumerable <AirSyncAttachmentInfo> attachments) { Item item = base.XsoItem as Item; attachments = null; if (item == null) { totalDataSize = 0L; return(null); } Stream stream; if (string.Equals(item.ClassName, "IPM.Note.SMIME", StringComparison.OrdinalIgnoreCase) && truncationSize != 0L) { string smimenotSupportedBodyHtml = XsoBodyPartProperty.GetSMIMENotSupportedBodyHtml(item.Session); stream = new MemoryStream(Encoding.UTF8.GetBytes(smimenotSupportedBodyHtml)); totalDataSize = stream.Length; return(stream); } switch (type) { case BodyType.None: case BodyType.PlainText: case BodyType.Rtf: case BodyType.Mime: throw new ConversionException(string.Format("Invalid body type requested: {0}", type)); case BodyType.Html: { ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null); if (valueOrDefault == null) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, false) { ErrorStringForProtocolLogger = "NoConversationIdForItem" }; } Conversation conversation; bool orCreateConversation = Command.CurrentCommand.GetOrCreateConversation(valueOrDefault, true, out conversation); if (conversation == null) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, false) { ErrorStringForProtocolLogger = "ConversationObjectLoadFailedForItem" }; } if (orCreateConversation) { conversation.LoadItemParts(new List <StoreObjectId> { item.StoreObjectId }); } IConversationTreeNode conversationTreeNode = null; if (!conversation.ConversationTree.TryGetConversationTreeNode(item.StoreObjectId, out conversationTreeNode)) { AirSyncDiagnostics.TraceError <StoreObjectId>(ExTraceGlobals.AirSyncTracer, this, "Cannot find itemId {0} in conversation tree!", item.StoreObjectId); totalDataSize = 0L; return(null); } bool flag = false; AirSyncDiagnostics.FaultInjectionTracer.TraceTest <bool>(3970313533U, ref flag); if (flag) { totalDataSize = 0L; return(null); } ItemPart itemPart = conversation.GetItemPart(item.StoreObjectId); if (!itemPart.DidLoadSucceed) { AirSyncDiagnostics.TraceError(ExTraceGlobals.AirSyncTracer, this, "ItemPart.DidLoadSucceed is false!"); stream = null; totalDataSize = 0L; return(stream); } using (AirSyncStream airSyncStream = new AirSyncStream()) { try { using (HtmlWriter htmlWriter = new HtmlWriter(airSyncStream, Encoding.UTF8)) { itemPart.WriteUniquePart(htmlWriter); htmlWriter.Flush(); } } catch (TextConvertersException innerException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, innerException, false); } airSyncStream.Seek(0L, SeekOrigin.Begin); stream = new AirSyncStream(); uint streamHash; StreamHelper.CopyStream(airSyncStream, stream, Encoding.UTF8, (int)truncationSize, true, out streamHash); ((AirSyncStream)stream).StreamHash = (int)streamHash; totalDataSize = ((truncationSize < 0L || airSyncStream.Length < truncationSize) ? stream.Length : airSyncStream.Length); Dictionary <AttachmentId, AirSyncAttachmentInfo> dictionary = null; if (itemPart.Attachments != null && itemPart.Attachments.Count > 0) { dictionary = itemPart.Attachments.ToDictionary((AttachmentInfo x) => x.AttachmentId, (AttachmentInfo x) => new AirSyncAttachmentInfo { AttachmentId = x.AttachmentId, IsInline = x.IsInline, ContentId = x.ContentId }); } Dictionary <AttachmentId, string> dictionary2; Command.CurrentCommand.InlineAttachmentContentIdLookUp.TryGetValue(item.Id.ObjectId, out dictionary2); if (dictionary2 != null) { if (dictionary != null) { foreach (KeyValuePair <AttachmentId, string> keyValuePair in dictionary2) { AirSyncAttachmentInfo airSyncAttachmentInfo; if (dictionary.TryGetValue(keyValuePair.Key, out airSyncAttachmentInfo) && airSyncAttachmentInfo != null) { airSyncAttachmentInfo.IsInline = true; airSyncAttachmentInfo.ContentId = keyValuePair.Value; } else { dictionary[keyValuePair.Key] = new AirSyncAttachmentInfo { AttachmentId = keyValuePair.Key, IsInline = true, ContentId = keyValuePair.Value }; } } attachments = dictionary.Values; } else { attachments = from inlineAttachment in dictionary2 select new AirSyncAttachmentInfo { AttachmentId = inlineAttachment.Key, IsInline = true, ContentId = inlineAttachment.Value }; } } else { attachments = ((dictionary != null) ? dictionary.Values : null); } return(stream); } break; } } stream = null; totalDataSize = 0L; return(stream); }
// OLD BUILD /*protected override void Build() * { * var result = "<table data-sortable class=\"table table-striped table-bordered table-responsive table-hover sortable-theme-bootstrap\">" + * "<thead>" + * "<tr>" + * "<th>#</th>" + * "<th>Key</th>" + * "<th>Program</th>" + * "<th>File</th>" + * "</tr>" + * "</thead>" + * "<tbody>"; * var i = 0; * var autoruns = Autorun.GetAutoruns(); * foreach (var autorun in autoruns) * { * i++; * result += "<tr>" + * "<td class=\"index\">" + i + "</td>" + * "<td class=\"key\">" + autorun.Key + "</td>" + * "<td class=\"program\">" + autorun.Program + "</td>" + * "<td class=\"file\">" + autorun.Path + "</td>" + * "</tr>"; * } * * * result += "</tbody></table>"; * Html = result; * }*/ protected override void Build() { if (SystemHelper.IsWindows) { var icons = new Dictionary <string, string> { { "Logon", "fa fa-sign-in" }, { "Explorer", "fa fa-folder" }, { "Internet Explorer", "fa fa-globe" }, { "Tasks", "fa fa-clock-o" }, { "Services", "fa fa-cogs" }, { "Drivers", "fa fa-desktop" }, { "Codecs", "fa fa-play-circle" }, { "Boot Execute", "" }, { "Hijacks", "" }, { "Known DLLs", "fa fa-file-o" }, { "Winlogon", "" }, { "Print Monitors", "fa fa-print" }, { "LSA Providers", "fa fa-shield" }, { "Network Providers", "fa fa-wifi" }, { "WDM", "" }, { "WMI", "" }, { "Sidebar Gadgets", "" }, }; Managers.AutorunManager.Update(); var autorunsDict = Managers.AutorunManager.GetAsDictionary(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "nav nav-tabs"); HtmlWriter.AddAttribute("role", "tablist"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Ul); //result = "<ul class=\"nav nav-tabs\" role=\"tablist\">"; foreach (var autorunDict in autorunsDict) { if (autorunDict.Key.Equals("Logon")) { HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "active"); } HtmlWriter.AddAttribute("role", "presentation"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Li); var id = autorunDict.Key.Replace(" ", string.Empty); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, string.Format("#autorun_{0}", id)); HtmlWriter.AddAttribute("aria-controls", id); HtmlWriter.AddAttribute("role", "tab"); HtmlWriter.AddAttribute("data-toggle", "tab"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.A); if (icons.ContainsKey(autorunDict.Key)) { HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, icons[autorunDict.Key]); } HtmlWriter.RenderBeginTag(HtmlTextWriterTag.I); HtmlWriter.RenderEndTag(); // </i> HtmlWriter.Write(" {0} ({1})", autorunDict.Key, autorunDict.Value.Count); HtmlWriter.RenderEndTag(); // </a> HtmlWriter.RenderEndTag(); // </li> } HtmlWriter.RenderEndTag(); // </ul> HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tab-content"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); foreach (var autorunDict in autorunsDict) { HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, string.Format("autorun_{0}", autorunDict.Key.Replace(" ", string.Empty))); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tab-pane"); if (autorunDict.Key.Equals("Logon")) { HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "active"); } HtmlWriter.AddAttribute("role", "tabpanel"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); if (autorunDict.Value.Count == 0) { HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Strong); HtmlWriter.Write("No autorun entries under this category."); HtmlWriter.RenderEndTag(); // </strong> HtmlWriter.RenderEndTag(); // </p> continue; } HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "#"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, HtmlTextWriterAttribute.Width, "100", "Enabled"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Entry"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Description"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Publisher"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Image Path"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); var i = 0; foreach (var autorunEntry in autorunDict.Value.OrderBy(item => !item.Enabled).ThenBy(item => item.Entry)) { i++; if (!autorunEntry.IsValidFile) { HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "warning"); } HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "index", i.ToString()); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center enabled"); HtmlWriter.AddAttribute("data-order", Convert.ToByte(autorunEntry.Enabled).ToString()); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(autorunEntry.Enabled ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>"); HtmlWriter.RenderEndTag(); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "entry", autorunEntry.Entry); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "description", autorunEntry.Description); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "publisher", autorunEntry.Publisher); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "imagepath", autorunEntry.ImagePath); HtmlWriter.RenderEndTag(); // </tr> } HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> HtmlWriter.RenderEndTag(); // </div> } HtmlWriter.RenderEndTag(); // </div> } else { WriteNotSupportedMsg(); } }
public void Dispose() { HtmlWriter.Dispose(); HtmlStringWriter.Dispose(); }
private static void GenerateOutput(HtmlWriter writer, IEnumerable<SearchRecord> records) { Snippets.RenderNewsResults(writer, records.ToArray()); }
private static void RenderErrors(HtmlWriter writer) { if (Instance == null) return; foreach (var task in Instance.Tasks) { if (!string.IsNullOrEmpty(task.Error)) writer.RenderFullTag(HtmlTextWriterTag.P, task.Error); } }
protected virtual void RenderPart(HtmlWriter writer) { }
// Token: 0x060013BB RID: 5051 RVA: 0x00071A18 File Offset: 0x0006FC18 protected void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer) { AirSyncDiagnostics.Assert(context != null); string value = filterAttribute.Value; AttachmentLink attachmentLink = this.IsInlineReference(value); if (attachmentLink != null) { this.OutputInlineReference(filterAttribute, attachmentLink, writer); return; } if (SafeHtmlCallback.IsSafeUrl(filterAttribute.Value, filterAttribute.Id)) { filterAttribute.Write(); } }
protected void RenderOutput(SiteSearchResultPage item, HtmlWriter writer) { IEnumerable<SearchRecord> records = _result.Records; records = _pager.Visible ? records.Skip(_pager.Skip).Take(_pager.Take) : records.Take(_page.MaxItemsShown); var page = CmsService.Instance.GetItem<SiteSearchResultPage>(); if (!page.Intro.IsEmpty) { var query = SearchFilter.FromUrl().Query; var intro = page.Intro.AsHtml.Replace("[QUERY]", string.IsNullOrEmpty(query) ? "" : string.Format("<span class=\"search-word\">{0}</span>", HttpUtility.HtmlEncode(query))); writer.RenderFullTag(HtmlTextWriterTag.H2, intro, "intro"); } RenderResults(writer, records.ToArray()); }
// Token: 0x060013B9 RID: 5049 RVA: 0x00071894 File Offset: 0x0006FA94 protected void OutputInlineReference(HtmlTagContextAttribute filterAttribute, AttachmentLink link, HtmlWriter writer) { AttachmentPolicy.Level attachmentLevel = this.GetAttachmentLevel(link); if (AttachmentPolicy.Level.Allow != attachmentLevel) { this.hasBlockedImagesInCurrentPass = true; this.hasBlockedInlineAttachments = true; writer.WriteAttribute(filterAttribute.Id, " "); return; } if (!this.isembeddedItem) { StringBuilder stringBuilder = new StringBuilder("/Microsoft-Server-ActiveSync?Cmd=GetAttachment&AttachmentName="); int num = 0; foreach (AttachmentLink attachmentLink in base.AttachmentLinks) { if (link.AttachmentId == attachmentLink.AttachmentId) { break; } num++; } stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}:{1}", new object[] { this.itemId.ToBase64String(), num }); writer.WriteAttribute(filterAttribute.Id, stringBuilder.ToString()); return; } filterAttribute.WriteName(); writer.WriteAttributeValue("cid:" + this.GetOrGenerateAttachContentId(link)); }
// Token: 0x060010D3 RID: 4307 RVA: 0x0006723C File Offset: 0x0006543C protected override void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer) { AttachmentLink attachmentLink = base.IsInlineImage(filterAttribute); if (attachmentLink != null) { base.OutputInlineReference(filterAttribute, context, attachmentLink, writer); return; } if (base.IsSafeUrl(filterAttribute.Value, filterAttribute.Id)) { this.hasBlockedImages = true; } }
public void RenderVideoModule(HtmlWriter writer, string videoId) { var video = GetVideo(videoId); if (video != null) video.Render(writer); }
private void Start() { Abort = false; ClearPassFailResultColumn(); dataGridView1[(int)ColText.PASSFAIL, 0].Value = "Starting..."; dataGridView1.Refresh(); if (Tm.TestClass is IPowerSupply) { (Tm.TestClass as IPowerSupply).SetSupplyState(false); Thread.Sleep(750); } new Thread(() => { try { Thread.CurrentThread.Name = "Test Runner"; Log.WriteLine(LogType.General, "Test thread started."); if (Form1.AppSettings.UseDb) { Db.OpenExisting(Form1.AppSettings.DbConnectString); Log.WriteLine(LogType.General, "Database opened"); } HtmlWriter html = new HtmlWriter(ReportDirectory); bool allPassed = true; string opMessage = ""; Guid testGroup = Guid.NewGuid(); for (int i = 0; i < Form1.AppSettings.TestList.Count; i++) { dataGridView1[(int)ColText.PASSFAIL, i].Style.BackColor = Color.White; } Tm.LocalStash = new Dictionary <string, string>(); for (int i = 0; i < Form1.AppSettings.TestList.Count; i++) { if (Abort) { dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1[(int)ColText.PASSFAIL, i].Value = "Aborted..."; }); allPassed = false; break; } else { dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1[(int)ColText.PASSFAIL, i].Value = "Running..."; }); } dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1[(int)ColText.TARGET, i].Value = Form1.AppSettings.TestList[i].GetTestLimits(); dataGridView1.FirstDisplayedScrollingRowIndex = i > 2 ? i - 2 : 0; }); while (Pause) { Thread.Sleep(500); } TestResult tr = null; if (Form1.AppSettings.TestList[i] is AudioTestBase) { for (int j = 0; j < ((AudioTestBase)Form1.AppSettings.TestList[i]).RetryCount; j++) { if (j > 0) { dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1[(int)ColText.PASSFAIL, i].Value = "Retry: " + j.ToString(); }); } Form1.AppSettings.TestList[i].DoTest(Form1.AppSettings.TestList[i].Name, out tr); if (tr.Pass) { break; } } } else { Form1.AppSettings.TestList[i].DoTest(Form1.AppSettings.TestList[i].Name, out tr); } if (Form1.AppSettings.AbortOnFailure && (tr.Pass == false)) { Abort = true; } if (tr.Pass == false) { allPassed = false; } // any test can update the operator message. But only the last test that updates // the operator message will have its result shown. if (tr.OperatorMessage != "") { opMessage = tr.OperatorMessage; } dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1[(int)ColText.L, i].Value = tr.StringValue[0]; dataGridView1[(int)ColText.R, i].Value = tr.StringValue[1]; dataGridView1[(int)ColText.PASSFAIL, i].Value = tr.Pass ? "PASS" : "FAIL"; dataGridView1[(int)ColText.PASSFAIL, i].Style.BackColor = tr.Pass ? Color.Green : Color.Red; dataGridView1.Refresh(); }); // Delineate new tests if (i == 0) { html.AddParagraph("================================================"); html.AddHeading2(string.Format("{0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString())); } // If new test AND first test is serial number, then print it larger if (i == 0 && (Form1.AppSettings.TestList[0] is IdInputA00)) { html.AddHeading2(string.Format("Device SN: {0}", tr.StringValue[0])); } html.AddParagraph(string.Format("<B>Test Name:</B> {0} <B>Result L:</B> {1} <B>Result R:</B> {2} <B>P/F</B>: {3} <B>Image:</B> {4}", Form1.AppSettings.TestList[i].Name, tr.StringValue[0], tr.StringValue[1], tr.Pass ? "PASS" : "<mark>FAIL</mark>", Form1.AppSettings.TestList[i].TestResultBitmap == null ? "[No Image]" : html.ImageLink("Screen", Form1.AppSettings.TestList[i].TestResultBitmap) )); if (Form1.AppSettings.UseAuditDb) { if (Form1.AppSettings.TestList[i] is AudioTestBase) { if (((AudioTestBase)Form1.AppSettings.TestList[i]).LeftChannel) { SubmitToAuditDb(testGroup, 0, Form1.AppSettings.TestList[i], tr); } if (((AudioTestBase)Form1.AppSettings.TestList[i]).RightChannel) { SubmitToAuditDb(testGroup, 1, Form1.AppSettings.TestList[i], tr); } } else { SubmitToAuditDb(testGroup, 0, Form1.AppSettings.TestList[i], tr); } } // Add to database if needed if (Form1.AppSettings.UseDb) { if (Form1.AppSettings.TestList[i] is AudioTestBase) { // Left channel if (((AudioTestBase)Form1.AppSettings.TestList[i]).LeftChannel) { SubmitToDb(testGroup, 0, Form1.AppSettings.TestList[i], tr); } if (((AudioTestBase)Form1.AppSettings.TestList[i]).RightChannel) { SubmitToDb(testGroup, 1, Form1.AppSettings.TestList[i], tr); } } else { SubmitToDb(testGroup, 0, Form1.AppSettings.TestList[i], tr); } } if (IsConnected() == false) { Log.WriteLine(LogType.Error, "Equipment is no longer connected. Testing will now stop."); dataGridView1[(int)ColText.PASSFAIL, i].Value = "ERROR"; throw new InvalidOperationException("Equipment is no longer connected. Testing will now stop."); } } TimeSpan ts = DateTime.Now.Subtract(TestStartTime); html.AddParagraph(string.Format("Elapsed Time: {0:N1} sec", ts.TotalSeconds)); html.Render(); this.Invoke(((MethodInvoker) delegate { TestPassFinished(allPassed, allPassed ? opMessage : ""); })); } catch (Exception ex) { Log.WriteLine(LogType.Error, ex.Message); this.Invoke(((MethodInvoker) delegate { TestPassFinished(false, ""); })); } if (Tm.TestClass is IPowerSupply) { (Tm.TestClass as IPowerSupply).SetSupplyState(false); } }).Start(); }
internal override void WriteTo(HtmlWriter writer) { writer.Write(Value); }
public void TestHtmlWriter() { const string expected = "<html ltr=\"true\"><head/><body>" + "<p class=\"paragraph\" style=\"font: arial; color: red\" align=\"left\">" + "special characters in this text should get encoded: <>'&\n<br/><br/></p>" + "<p class=\"paragraph\" style=\"font: arial; color: red\" align=\"left\">" + "special characters should not get encoded: <>" + "</p><p></p>" + "<p class=\"paragraph\" style=\"font: arial; color: red\" align=\"left\">" + "special characters in this text should get encoded: <>'&\n<br/><br/></p>" + "<p class=\"paragraph\" style=\"font: arial; color: red\" align=\"left\">" + "special characters should not get encoded: <>" + "</p></body></html>"; var text = "special characters in this text should get encoded: <>'&\n"; var markup = "special characters should not get encoded: <>"; var style = "font: arial; color: red"; var actual = new StringBuilder(); using (var html = new HtmlWriter(new StringWriter(actual))) { Assert.AreEqual(HtmlWriterState.Default, html.WriterState); // make sure we can't start by writing an attribute since we are in the wrong state Assert.Throws <InvalidOperationException> (() => html.WriteAttribute(new HtmlAttribute(HtmlAttributeId.Action, "invalid state"))); Assert.Throws <InvalidOperationException> (() => html.WriteAttribute(HtmlAttributeId.Action, "invalid state")); Assert.Throws <InvalidOperationException> (() => html.WriteAttribute("action", "invalid state")); // write a tag html.WriteStartTag(HtmlTagId.Html); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); // *now* we should be able to write an attribute html.WriteAttribute(new HtmlAttribute("ltr", "true")); // write en empty element tag, this should change the state to Default html.WriteEmptyElementTag(HtmlTagId.Head); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteStartTag("body"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteStartTag(HtmlTagId.P); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); // make sure that we can't write an attribute value yet Assert.Throws <InvalidOperationException> (() => html.WriteAttributeValue("attrValue")); Assert.Throws <InvalidOperationException> (() => html.WriteAttributeValue("attrValue".ToCharArray(), 0, 9)); html.WriteAttributeName(HtmlAttributeId.Class); Assert.AreEqual(HtmlWriterState.Attribute, html.WriterState); html.WriteAttributeValue("paragraph"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteAttributeName("style"); Assert.AreEqual(HtmlWriterState.Attribute, html.WriterState); html.WriteAttributeValue(style.ToCharArray(), 0, style.Length); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteAttribute(HtmlAttributeId.Align, "left"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteText(text); Assert.AreEqual(HtmlWriterState.Default, html.WriterState); html.WriteEmptyElementTag("br"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteEmptyElementTag("br"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteEndTag("p"); Assert.AreEqual(HtmlWriterState.Default, html.WriterState); Assert.Throws <InvalidOperationException> (() => html.WriteAttributeName("style")); Assert.Throws <InvalidOperationException> (() => html.WriteAttributeName(HtmlAttributeId.Style)); html.WriteStartTag("p"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteAttribute(HtmlAttributeId.Class, "paragraph".ToCharArray(), 0, "paragraph".Length); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteAttribute("style", style.ToCharArray(), 0, style.Length); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteAttribute("align", "left"); Assert.AreEqual(HtmlWriterState.Tag, html.WriterState); html.WriteMarkupText(markup); Assert.AreEqual(HtmlWriterState.Default, html.WriterState); html.WriteEndTag(HtmlTagId.P); Assert.AreEqual(HtmlWriterState.Default, html.WriterState); html.WriteStartTag(HtmlTagId.P); html.WriteEndTag(HtmlTagId.P); html.WriteStartTag("p"); html.WriteAttribute("class", "paragraph"); html.WriteAttribute("style", style); html.WriteAttribute("align", "left"); html.WriteText(text.ToCharArray(), 0, text.Length); html.WriteEmptyElementTag("br"); html.WriteEmptyElementTag("br"); html.WriteEndTag("p"); html.WriteStartTag("p"); html.WriteAttribute("class", "paragraph"); html.WriteAttribute("style", style); html.WriteAttribute("align", "left"); html.WriteMarkupText(markup.ToCharArray(), 0, markup.Length); html.WriteEndTag("p"); html.WriteEndTag(HtmlTagId.Body); html.WriteEndTag("html"); html.Flush(); } Assert.AreEqual(expected, actual.ToString()); }
// Token: 0x060013AB RID: 5035 RVA: 0x00071114 File Offset: 0x0006F314 public override void ProcessTag(HtmlTagContext context, HtmlWriter writer) { if (context == null) { throw new ArgumentNullException("context"); } bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; string text = null; string text2 = null; string text3 = null; if (context.TagId == HtmlTagId.Link) { bool writeTag = SafeHtmlCallback.WriteTagWithMicroData(context); SafeHtmlCallback.ProcessMicrodataTag(writeTag, context, SafeHtmlCallback.linkTagAttributes); return; } if (context.TagId == HtmlTagId.Head) { context.WriteTag(true); return; } if (context.TagId == HtmlTagId.Meta) { bool writeTag2 = SafeHtmlCallback.WriteTagWithMicroData(context); SafeHtmlCallback.ProcessMicrodataTag(writeTag2, context, SafeHtmlCallback.metaTagAttributes); return; } if (context.TagId == HtmlTagId.Base) { foreach (HtmlTagContextAttribute attribute in context.Attributes) { if (SafeHtmlCallback.IsBaseTag(context.TagId, attribute)) { string value = attribute.Value; if (!Uri.TryCreate(value, UriKind.Absolute, out this.baseRef)) { this.baseRef = null; break; } break; } } } context.WriteTag(); bool flag5 = false; foreach (HtmlTagContextAttribute htmlTagContextAttribute in context.Attributes) { if (context.TagId == HtmlTagId.Form || context.TagId == HtmlTagId.Input) { if (htmlTagContextAttribute.Id != HtmlAttributeId.Src && htmlTagContextAttribute.Id != HtmlAttributeId.Action && htmlTagContextAttribute.Id != HtmlAttributeId.Method && htmlTagContextAttribute.Id != HtmlAttributeId.Target) { htmlTagContextAttribute.Write(); } } else if (htmlTagContextAttribute.Id != HtmlAttributeId.UseMap) { if (SafeHtmlCallback.IsUrlTag(context.TagId, htmlTagContextAttribute)) { if (!flag) { this.ProcessHtmlUrlTag(htmlTagContextAttribute, writer); flag = true; } } else if (SafeHtmlCallback.IsImageTag(context.TagId, htmlTagContextAttribute)) { if ((htmlTagContextAttribute.Id == HtmlAttributeId.Src && !flag2) || (htmlTagContextAttribute.Id == HtmlAttributeId.DynSrc && !flag3) || (htmlTagContextAttribute.Id == HtmlAttributeId.LowSrc && !flag4)) { this.ProcessImageTag(htmlTagContextAttribute, context, writer); if (htmlTagContextAttribute.Value == "rtfimage://") { flag5 = true; } if (htmlTagContextAttribute.Id == HtmlAttributeId.Src) { flag2 = true; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.DynSrc) { flag3 = true; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.LowSrc) { flag4 = true; } } } else if (SafeHtmlCallback.IsBackgroundAttribute(htmlTagContextAttribute)) { this.ProcessImageTag(htmlTagContextAttribute, context, writer); } else if (!SafeHtmlCallback.IsTargetTagInAnchor(context.TagId, htmlTagContextAttribute)) { if (SafeHtmlCallback.IsSanitizingAttribute(htmlTagContextAttribute)) { if (htmlTagContextAttribute.Id == HtmlAttributeId.Border) { text = htmlTagContextAttribute.Value; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.Height) { text2 = htmlTagContextAttribute.Value; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.Width) { text3 = htmlTagContextAttribute.Value; } } else { htmlTagContextAttribute.Write(); } } } } if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3) && this.hasBlockedImagesInCurrentPass) { SafeHtmlCallback.SanitizeImage(writer, text, text2, text3); } else if (!this.hasBlockedImagesInCurrentPass) { if (flag5) { writer.WriteAttribute(HtmlAttributeId.Height, "0"); writer.WriteAttribute(HtmlAttributeId.Width, "0"); } else { if (!string.IsNullOrEmpty(text2)) { writer.WriteAttribute(HtmlAttributeId.Height, text2); } if (!string.IsNullOrEmpty(text3)) { writer.WriteAttribute(HtmlAttributeId.Width, text3); } if (!string.IsNullOrEmpty(text)) { writer.WriteAttribute(HtmlAttributeId.Border, text); } } } if (this.hasFoundRedirUrlInCurrentPass) { writer.WriteAttribute(HtmlAttributeId.Target, "_BLANK"); } this.hasBlockedImagesInCurrentPass = false; this.hasFoundRedirUrlInCurrentPass = false; }
internal override void WriteTo(HtmlWriter writer) { writer.Write(this.ToString()); }
public void Format(string input, TextWriter output) { // Determine if we are outputting xhtml bool makeXhtml = true; // Save the max line length int maxLineLength = this._maxLineLength; // Make the indent string string indentString = new String(this._indentChar, this._indentSize); char[] chars = input.ToCharArray(); Stack tagStack = new Stack(); Stack writerStack = new Stack(); // The previous begin or end tag that was seen FormatInfo previousTag = null; // The current begin or end tag that was seen FormatInfo currentTag = null; // The text between previousTag and currentTag string text = String.Empty; // True if we've seen whitespace at the end of the last text outputted bool sawWhiteSpace = false; // True if the last tag seen was self-terminated with a '/>' bool sawSelfTerminatingTag = false; // True if we saw a tag that we decided not to render bool ignoredLastTag = false; // Put the initial writer on the stack HtmlWriter writer = new HtmlWriter(output, indentString, maxLineLength); writerStack.Push(writer); Token t = HtmlTokenizer.GetFirstToken(chars); Token lastToken = t; while (t != null) { writer = (HtmlWriter)writerStack.Peek(); switch (t.Type) { case Token.AttrName: if (makeXhtml) { string attrName = String.Empty; if (!previousTag.tagInfo.IsXml) { // Need to lowercase the HTML attribute names for XHTML attrName = t.Text.ToLower(); } else { attrName = t.Text; } writer.Write(attrName); // If we are trying to be compliant XHTML, don't allow attribute minimization Token nextToken = HtmlTokenizer.GetNextToken(t); if (nextToken.Type != Token.EqualsChar) { writer.Write("=\"" + attrName + "\""); } } else { // Convert the case of the attribute if the tag isn't xml if (!previousTag.tagInfo.IsXml) { if (this._attributeCasing == HtmlFormatterCase.UpperCase) { writer.Write(t.Text.ToUpper()); } else if (this._attributeCasing == HtmlFormatterCase.LowerCase) { writer.Write(t.Text.ToLower()); } else { writer.Write(t.Text); } } else { writer.Write(t.Text); } } break; case Token.AttrVal: if (makeXhtml && (lastToken.Type != Token.DoubleQuote) && (lastToken.Type != Token.SingleQuote)) { // If the attribute value isn't quoted, double quote it, replacing the inner double quotes writer.Write('\"'); writer.Write(t.Text.Replace("\"", """)); writer.Write('\"'); } else { writer.Write(t.Text); } break; case Token.CloseBracket: if (makeXhtml) { if (ignoredLastTag) { // Don't render the close bracket if we ignored the last tag ignoredLastTag = false; } else { if (sawSelfTerminatingTag && (!previousTag.tagInfo.IsComment)) { // If we saw a self terminating tag, that doesn't have the forward slash, put it in (except for comments) writer.Write(" />"); } else { // If we are just closing a normal tag, just put in a normal close bracket writer.Write('>'); } } } else { // If there's no XHTML to be made, just put in a normal close bracket writer.Write('>'); } break; case Token.DoubleQuote: writer.Write('\"'); break; case Token.Empty: break; case Token.EqualsChar: writer.Write('='); break; case Token.Error: if (lastToken.Type == Token.OpenBracket) { // Since we aren't outputting open brackets right away, we might have to output one now writer.Write('<'); } writer.Write(t.Text); break; case Token.ForwardSlash: case Token.OpenBracket: // Just push these symbols on the stack for now... output them when we write the tag break; case Token.SelfTerminating: previousTag.isEndTag = true; if (!previousTag.tagInfo.NoEndTag) { // If the tag that is self-terminating is normally not a self-closed tag // then we've placed an entry on the stack for it. Since it's self terminating, we now need // to pop that item off of the tag stack tagStack.Pop(); // If it was a self-closed Xml tag, then we also need to clean up the writerStack if (previousTag.tagInfo.IsXml) { HtmlWriter oldWriter = (HtmlWriter)writerStack.Pop(); writer = (HtmlWriter)writerStack.Peek(); // Since a self-closed xml tag can't have any text content, we can just write out the formatted contents writer.Write(oldWriter.Content); } } if ((lastToken.Type == Token.Whitespace) && (lastToken.Text.Length > 0)) { writer.Write("/>"); } else { writer.Write(" />"); } break; case Token.SingleQuote: writer.Write('\''); break; case Token.XmlDirective: writer.WriteLineIfNotOnNewLine(); writer.Write('<'); writer.Write(t.Text); writer.Write('>'); writer.WriteLineIfNotOnNewLine(); ignoredLastTag = true; break; case Token.TagName: case Token.Comment: case Token.InlineServerScript: string tagName; // Reset the self terminating tag flag sawSelfTerminatingTag = false; // Create or get the proper tagInfo, depending on the type of token TagInfo info; if (t.Type == Token.Comment) { // Handle comment tags tagName = t.Text; info = new TagInfo(t.Text, commentTag); } else if (t.Type == Token.InlineServerScript) { // Handle server-side script tags string script = t.Text.Trim(); script = script.Substring(1); tagName = script; if (script.StartsWith("%@")) { // Directives are block tags info = new TagInfo(script, directiveTag); } else { // Other server side script tags aren't info = new TagInfo(script, otherServerSideScriptTag); } } else { // Otherwise, this is a normal tag, and try to get a TagInfo for it tagName = t.Text; info = tagTable[tagName] as TagInfo; if (info == null) { // if we couldn't find one, create a copy of the unknownTag with a new tagname if (tagName.IndexOf(':') > -1) { // If it is a prefixed tag, it's probably unknown XML info = new TagInfo(tagName, unknownXmlTag); } else if (writer is XmlWriter) { info = new TagInfo(tagName, nestedXmlTag); } else { // If it is a not prefixed, it's probably an unknown HTML tag info = new TagInfo(tagName, unknownHtmlTag); } } else { // If it's not an unknown tag, converting to the desired case (and leave as is for PreserveCase) if ((this._elementCasing == HtmlFormatterCase.LowerCase) || makeXhtml) { tagName = info.TagName; } else if (this._elementCasing == HtmlFormatterCase.UpperCase) { tagName = info.TagName.ToUpper(); } } } if (previousTag == null) { // Special case for the first tag seen previousTag = new FormatInfo(info, false); // Since this is the first tag, set it's indent to 0 previousTag.indent = 0; // Push it on the stack tagStack.Push(previousTag); // And output the preceeding text writer.Write(text); if (info.IsXml) { // When we encounter an xml block, create a new writer to contain the inner content of the xml HtmlWriter newWriter = new XmlWriter(writer.Indent, info.TagName, indentString, maxLineLength); writerStack.Push(newWriter); writer = newWriter; } if (lastToken.Type == Token.ForwardSlash) { // If this is an end tag, output the proper prefix writer.Write("</"); } else { writer.Write('<'); } // Write the name writer.Write(tagName); // Indicate that we've written out the last text block text = String.Empty; } else { // Put the new tag in the next spot currentTag = new FormatInfo(info, (lastToken.Type == Token.ForwardSlash)); WhiteSpaceType whiteSpaceType; if (previousTag.isEndTag) { // If the previous tag is an end tag, we need to check the following whitespace whiteSpaceType = previousTag.tagInfo.FollowingWhiteSpaceType; } else { // otherwise check the initial inner whitespace whiteSpaceType = previousTag.tagInfo.InnerWhiteSpaceType; } // Flag that indicates if the previous tag (before the text) is an inline tag bool inline = previousTag.tagInfo.IsInline; bool emptyXml = false; bool firstOrLastUnknownXmlText = false; if (writer is XmlWriter) { // if we're in an xml block XmlWriter xmlWriter = (XmlWriter)writer; if (xmlWriter.IsUnknownXml) { // Special case for unknown XML tags // Determine if this is the first or last xml text in an unknown xml tag, so we know to preserve the text content here firstOrLastUnknownXmlText = (((previousTag.isBeginTag) && (previousTag.tagInfo.TagName.ToLower() == xmlWriter.TagName.ToLower())) || ((currentTag.isEndTag) && (currentTag.tagInfo.TagName.ToLower() == xmlWriter.TagName.ToLower()))) && (!FormattedTextWriter.IsWhiteSpace(text)); } if (previousTag.isBeginTag) { if (FormattedTextWriter.IsWhiteSpace(text)) { if ((xmlWriter.IsUnknownXml) && (currentTag.isEndTag) && (previousTag.tagInfo.TagName.ToLower() == currentTag.tagInfo.TagName.ToLower())) { // Special case for unknown XML tags: // If the previous tag is an open tag and the next tag is the corresponding close tag and the text is only whitespace, also // treat the tag as inline, so the begin and end tag appear on the same line inline = true; emptyXml = true; // Empty the text since we want the open and close tag to be touching text = ""; } } else { if (!xmlWriter.IsUnknownXml) { // If there is non-whitespace text and we're in a normal Xml block, then remember that there was text xmlWriter.ContainsText = true; } } } } // Flag that indicates if we want to preserve whitespace in the front of the text bool frontWhitespace = true; if ((previousTag.isBeginTag) && (previousTag.tagInfo.PreserveContent)) { // If the previous tag is a begin tag and we're preserving the content as-is, just write out the text writer.Write(text); } else { if (whiteSpaceType == WhiteSpaceType.NotSignificant) { // If the whitespace is not significant in this location if (!inline && !firstOrLastUnknownXmlText) { // If the previous tag is not an inline tag, write out a new line writer.WriteLineIfNotOnNewLine(); // Since we've written out a newline, we no longer need to preserve front whitespace frontWhitespace = false; } } else if (whiteSpaceType == WhiteSpaceType.Significant) { // If the whitespace in this location is significant if (FormattedTextWriter.HasFrontWhiteSpace(text)) { // If there is whitespace in the front, that means we can insert more whitespace without // changing rendering behavior if (!inline && !firstOrLastUnknownXmlText) { // Only insert a new line if the tag isn't inline writer.WriteLineIfNotOnNewLine(); frontWhitespace = false; } } } else if (whiteSpaceType == WhiteSpaceType.CarryThrough) { // If the whitespace in this location is carry through (meaning whitespace at the end of the previous // text block eats up any whitespace in this location if ((sawWhiteSpace) || (FormattedTextWriter.HasFrontWhiteSpace(text))) { // If the last text block ended in whitspace or if there is already whitespace in this location // we can add a new line if (!inline && !firstOrLastUnknownXmlText) { // Only add it if the previous tag isn't inline writer.WriteLineIfNotOnNewLine(); frontWhitespace = false; } } } if (previousTag.isBeginTag) { // If the previous tag is a begin tag if (!previousTag.tagInfo.NoIndent && !inline) { // Indent if desired writer.Indent++; } } // Special case for unknown XML tags: if (firstOrLastUnknownXmlText) { writer.Write(text); } else { writer.WriteLiteral(text, frontWhitespace); } } if (currentTag.isEndTag) { // If the currentTag is an end tag if (!currentTag.tagInfo.NoEndTag) { // Figure out where the corresponding begin tag is ArrayList popped = new ArrayList(); FormatInfo formatInfo = null; bool foundOpenTag = false; bool allowPartial = false; if ((currentTag.tagInfo.Flags & FormattingFlags.AllowPartialTags) != 0) { // Once we've exited a tag that allows partial tags, clear the flag allowPartial = true; } // Start popping off the tag stack if there are tags on the stack if (tagStack.Count > 0) { // Keep popping until we find the right tag, remember what we've popped off formatInfo = (FormatInfo)tagStack.Pop(); popped.Add(formatInfo); while ((tagStack.Count > 0) && (formatInfo.tagInfo.TagName.ToLower() != currentTag.tagInfo.TagName.ToLower())) { if ((formatInfo.tagInfo.Flags & FormattingFlags.AllowPartialTags) != 0) { // Special case for tags that allow partial tags inside of them. allowPartial = true; break; } formatInfo = (FormatInfo)tagStack.Pop(); popped.Add(formatInfo); } if (formatInfo.tagInfo.TagName.ToLower() != currentTag.tagInfo.TagName.ToLower()) { // If we didn't find the corresponding open tag, push everything back on for (int i = popped.Count - 1; i >= 0; i--) { tagStack.Push(popped[i]); } } else { foundOpenTag = true; for (int i = 0; i < popped.Count - 1; i++) { FormatInfo fInfo = (FormatInfo)popped[i]; if (fInfo.tagInfo.IsXml) { // If we have an xml tag that was unclosed, we need to clean up the xml stack if (writerStack.Count > 1) { HtmlWriter oldWriter = (HtmlWriter)writerStack.Pop(); writer = (HtmlWriter)writerStack.Peek(); // Write out the contents of the old writer writer.Write(oldWriter.Content); } } if (!fInfo.tagInfo.NoEndTag) { writer.WriteLineIfNotOnNewLine(); writer.Indent = fInfo.indent; if ((makeXhtml) && (!allowPartial)) { // If we're trying to be XHTML compliant, close unclosed child tags // Don't close if we are under a tag that allows partial tags writer.Write("</"+fInfo.tagInfo.TagName+">"); } } } // Set the indent to the indent of the corresponding open tag writer.Indent = formatInfo.indent; } } if (foundOpenTag || allowPartial) { // Only write out the close tag if there was a corresponding open tag or we are under // a tag that allows partial tags if ((!emptyXml) && (!firstOrLastUnknownXmlText) && (!currentTag.tagInfo.IsInline) && (!currentTag.tagInfo.PreserveContent) && ( FormattedTextWriter.IsWhiteSpace(text) || FormattedTextWriter.HasBackWhiteSpace(text) || (currentTag.tagInfo.FollowingWhiteSpaceType == WhiteSpaceType.NotSignificant) ) && ( !(currentTag.tagInfo is TDTagInfo) || FormattedTextWriter.HasBackWhiteSpace(text) ) ) { // Insert a newline before the next tag, if allowed writer.WriteLineIfNotOnNewLine(); } // Write out the end tag prefix writer.Write("</"); // Finally, write out the tag name writer.Write(tagName); } else { ignoredLastTag = true; } if (currentTag.tagInfo.IsXml) { // If we have an xml tag that was unclosed, we need to clean up the xml stack if (writerStack.Count > 1) { HtmlWriter oldWriter = (HtmlWriter)writerStack.Pop(); writer = (HtmlWriter)writerStack.Peek(); // Write out the contents of the old writer writer.Write(oldWriter.Content); } } } else { ignoredLastTag = true; } } else { // If the currentTag is a begin tag bool done = false; // Close implicitClosure tags while (!done && (tagStack.Count > 0)) { // Peek at the top of the stack to see the last unclosed tag FormatInfo fInfo = (FormatInfo)tagStack.Peek(); // If the currentTag can't be a child of that tag, then we need to close that tag done = fInfo.tagInfo.CanContainTag(currentTag.tagInfo); if (!done) { // Pop it off and write a close tag for it // REVIEW: Will XML tags always be able to contained in any tag? If not we should be cleaning up the writerStack as well... tagStack.Pop(); writer.Indent = fInfo.indent; // If we're trying to be XHTML compliant, write in the end tags if (makeXhtml) { if (!fInfo.tagInfo.IsInline) { // Only insert a newline if we are allowed to writer.WriteLineIfNotOnNewLine(); } writer.Write("</"+fInfo.tagInfo.TagName+">"); } } } // Remember the indent so we can properly indent the corresponding close tag for this open tag currentTag.indent = writer.Indent; if ((!firstOrLastUnknownXmlText) && (!currentTag.tagInfo.IsInline) && (!currentTag.tagInfo.PreserveContent) && ( (FormattedTextWriter.IsWhiteSpace(text) || FormattedTextWriter.HasBackWhiteSpace(text)) || ( (text.Length == 0) && ( ((previousTag.isBeginTag) && (previousTag.tagInfo.InnerWhiteSpaceType == WhiteSpaceType.NotSignificant)) || ((previousTag.isEndTag) && (previousTag.tagInfo.FollowingWhiteSpaceType == WhiteSpaceType.NotSignificant)) ) ) ) ) { // Insert a newline before the currentTag if we are allowed to writer.WriteLineIfNotOnNewLine(); } if (!currentTag.tagInfo.NoEndTag) { // Only push tags with close tags onto the stack tagStack.Push(currentTag); } else { // If this tag doesn't have a close tag, remember that it is self terminating sawSelfTerminatingTag = true; } if (currentTag.tagInfo.IsXml) { // When we encounter an xml block, create a new writer to contain the inner content of the xml HtmlWriter newWriter = new XmlWriter(writer.Indent, currentTag.tagInfo.TagName, indentString, maxLineLength); writerStack.Push(newWriter); writer = newWriter; } writer.Write('<'); // Finally, write out the tag name writer.Write(tagName); } // Remember if the text ended in whitespace sawWhiteSpace = FormattedTextWriter.HasBackWhiteSpace(text); // Clear out the text, since we have already outputted it text = String.Empty; previousTag = currentTag; } break; case Token.ServerScriptBlock: case Token.ClientScriptBlock: case Token.Style: case Token.TextToken: // Remember all these types of tokens as text so we can output them between the tags if (makeXhtml) { // UNDONE: Need to implement this in the tokenizer, etc... text += t.Text.Replace(" ", " "); } else { text += t.Text; } break; case Token.Whitespace: if (t.Text.Length > 0) { writer.Write(' '); } break; default: Debug.Fail("Invalid token type!"); break; } // Remember what the last token was lastToken = t; // Get the next token t = HtmlTokenizer.GetNextToken(t); } if (text.Length > 0) { // Write out the last text if there is any writer.Write(text); } while (writerStack.Count > 1) { // If we haven't cleared out the writer stack, do it HtmlWriter oldWriter = (HtmlWriter)writerStack.Pop(); writer = (HtmlWriter)writerStack.Peek(); writer.Write(oldWriter.Content); } // Flush the writer original writer.Flush(); }
protected override void Build() { if (SystemHelper.IsWindows) { var services = ServiceController.GetServices().OrderBy(controller => - (int)controller.Status).ThenBy(controller => controller.DisplayName); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, TABLE_CLASS); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Table); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Thead); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "#"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Display Name"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Service Name"); //HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Service Type"); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center"); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Width, "180"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Th); HtmlWriter.Write("Can Pause/Continue"); HtmlWriter.RenderEndTag(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center"); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Width, "180"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Th); HtmlWriter.Write("Can Shutdown"); HtmlWriter.RenderEndTag(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center"); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Width, "180"); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Th); HtmlWriter.Write("Can Stop"); HtmlWriter.RenderEndTag(); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Status"); HtmlWriter.RenderEndTag(); // </tr> HtmlWriter.RenderEndTag(); // </thead> HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tbody); var i = 0; // try to find service name foreach (var service in services) { i++; HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "index", i.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "displayname", service.DisplayName); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "displayname", service.ServiceName); //HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "servicetype", service.ServiceType.ToString()); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center canpause"); HtmlWriter.AddAttribute("data-order" + "", Convert.ToByte(service.CanPauseAndContinue).ToString()); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(service.CanPauseAndContinue ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>"); HtmlWriter.RenderEndTag(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center canshutdown"); HtmlWriter.AddAttribute("data-order", Convert.ToByte(service.CanShutdown).ToString()); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(service.CanShutdown ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>"); HtmlWriter.RenderEndTag(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-center canstop"); HtmlWriter.AddAttribute("data-order", Convert.ToByte(service.CanStop).ToString()); HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(service.CanStop ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>"); HtmlWriter.RenderEndTag(); HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "status"); /*result += "<tr>" + * "<td class=\"index\">" + i + "</td>" + * "<td class=\"displayname\">" + service.DisplayName + "</td>" + * "<td class=\"servicename\">" + service.ServiceName + "</td>" + * "<td>" + service.ServiceType + "</td>" + * //"<td>" + service.MachineName + "</td>" + * "<td class=\"text-center canpause\" data-order=\"" + Convert.ToByte(service.CanPauseAndContinue) + "\">" + (service.CanPauseAndContinue ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>") + "</td>" + * "<td class=\"text-center canshutdown\" data-order=\"" + Convert.ToByte(service.CanShutdown) + "\">" + (service.CanShutdown ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>") + "</td>" + * "<td class=\"text-center canstop\" data-order=\"" + Convert.ToByte(service.CanStop) + "\">" + (service.CanStop ? "<span class=\"glyphicon glyphicon-ok text-success\"></span>" : "<span class=\"glyphicon glyphicon-remove text-error\"></span>") + "</td>" + * "<td class=\"";*/ switch (service.Status) { case ServiceControllerStatus.Paused: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-warning"); break; case ServiceControllerStatus.StartPending: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-primary"); break; case ServiceControllerStatus.Running: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-success"); break; case ServiceControllerStatus.Stopped: HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "text-danger"); break; } HtmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); HtmlWriter.Write(service.Status); HtmlWriter.RenderEndTag(); HtmlWriter.RenderEndTag(); // </tr> //result += " status\">" + service.Status + "</td>" + // "</tr>"; } //result += "</tbody></table>"; HtmlWriter.RenderEndTag(); // </tbody> HtmlWriter.RenderEndTag(); // </table> } else { WriteNotSupportedMsg(); } }
private void RenderOutput(HtmlWriter writer) { var provider = new LinqIt.UmbracoCustomFieldTypes.UmbracoTreeModuleProvider(Request.QueryString["itemId"]); var placeholderData = provider.GetPlaceholderData(); var layout = provider.GetLayout(); var cells = layout.GetPlaceholderCells(); foreach (var placeholder in placeholderData.Keys.Where(k => placeholderData[k].Items.Any())) { writer.AddAttribute("ref", placeholder); writer.RenderBeginTag(HtmlTextWriterTag.Div, "cell"); writer.RenderFullTag(HtmlTextWriterTag.H3, placeholder); foreach (var item in placeholderData[placeholder].Items) { var cell = cells.Where(c => string.Compare(c.Key, placeholder, true) == 0).FirstOrDefault(); writer.AddAttribute("ref", item.Id); writer.AddClass("module"); if (item.IsLocal) writer.AddClass("local"); else writer.AddClass("global"); writer.RenderBeginTag(HtmlTextWriterTag.Div); var gridItem = provider.GetItem(item.Id); writer.RenderFullTag(HtmlTextWriterTag.H4, gridItem.Text); var columnSpan = item.ColumnSpan; var options = provider.GetItemColumnOptions(item.Id); if (cell != null && cell.ColumnSpan < columnSpan) { var validOptions = options.Where(o => o <= cell.ColumnSpan); if (validOptions.Any()) columnSpan = validOptions.Max(); else cell = null; } RenderDropDown(writer, cells, cell, options); writer.RenderBeginTag(HtmlTextWriterTag.Em); //if (cell == null) //{ // writer.RenderFullTag(HtmlTextWriterTag.Span, _removedMessage, "alert"); //} //else if (columnSpan < item.ColumnSpan) //{ // writer.RenderFullTag(HtmlTextWriterTag.Span, string.Format(_resizedMessage, columnSpan), "info"); //} writer.RenderEndTag(); writer.RenderEndTag(); } writer.RenderEndTag(); } }
private static void GenerateOutput(HtmlWriter writer) { var page = CmsService.Instance.GetItem<UmbracoPublic.Logic.Entities.SiteSearchResultPage>(); if (!string.IsNullOrEmpty(page.Headline)) writer.RenderFullTag(HtmlTextWriterTag.H1, page.Headline); }