public void EchoTag(string tag, string text, object attributes = null) { using (HtmlTagWriter w = new HtmlTagWriter(this.m_ctx, tag, attributes)) { w.EchoEscaped(text); } }
private static void Heading(HtmlTagWriter container) { using (var table = container.Tag("table")) { Action <string, string> Line = (name, value) => { using (var tr = table.Tag("tr")) { tr.EchoTag("td", name, new { @class = "e" }); tr.EchoTag("td", value, new { @class = "v" }); } }; Line("System", $"{GetOsName()} {Environment.MachineName} {RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture}"); Line("Architecture", RuntimeInformation.ProcessArchitecture.ToString()); Line("Debug build", #if DEBUG true #else false #endif ? "yes":"no"); Line("IPv6 Support", System.Net.Sockets.Socket.OSSupportsIPv6 ? "yes" : "no"); } }
private static void PageTitle(HtmlTagWriter container) { using (var table = container.Tag("table")) using (var tr = table.Tag("tr", new { @class = "h" })) using (var td = tr.Tag("td")) { using (var a = td.Tag("a", new { href = Resource.LogoHref, target = "_blank" })) { a.EchoTagSelf("img", new { border = "0", src = Resource.LogoSrc, alt = Resource.LogoAlt }); } using (var title = td.Tag("h1", new { @class = "p" })) { title.EchoEscaped("PeachPie Version " + typeof(Context).GetTypeInfo().Assembly.GetName().Version); } } }
private static void Variables(HtmlTagWriter container) { container.EchoTag("h2", "PHP Variables"); using (var table = container.Tag("table")) { using (var tr = table.Tag("tr", new { @class = "h" })) { tr.EchoTag("th", "Variable"); tr.EchoTag("th", "Value"); } Action <string, string> Line = (name, value) => { using (var tr = table.Tag("tr", new { @class = "h" })) { tr.EchoTag("td", name, new { @class = "e" }); using (var td = tr.Tag("td", new { @class = "v" })) { if (string.IsNullOrEmpty(value)) { td.EchoRaw(" "); } else { td.EchoEscaped(value); } } } }; Action <PhpArray, string> DumpArray = (arr, name) => { foreach (var entry in arr.Keys) { Line($"{name}[{entry}]", arr[entry].ToStringOrNull()); } }; DumpArray(container.Context.Cookie, "_COOKIE"); DumpArray(container.Context.Server, "_SERVER"); } }
private static void Env(HtmlTagWriter container) { container.EchoTag("h2", "Environment"); using (var table = container.Tag("table")) { using (var tr = table.Tag("tr", new { @class = "h" })) { tr.EchoTag("th", "Variable"); tr.EchoTag("th", "Value"); } Action <string, string> Line = (name, value) => { using (var tr = table.Tag("tr", new { @class = "h" })) { tr.EchoTag("td", name, new { @class = "e" }); using (var td = tr.Tag("td", new { @class = "v" })) { if (string.IsNullOrEmpty(value)) { td.EchoRaw(" "); } else { td.EchoEscaped(value); } } } }; foreach (var entry in container.Context.Env.Keys) { Line(entry.ToString(), container.Context.Env[entry].ToStringOrNull()); } } }
private static void Configuration(HtmlTagWriter container) { //TODO : get extensions and dump configuration }
private static void Credits(HtmlTagWriter container) { //TODO creditz }
public static HtmlTagWriter Tag(this HtmlTagWriter tagWriter, string tag, object attributes = null) { return(new HtmlTagWriter(tagWriter.Context, tag, attributes)); }