private Task HandleListRequest(HttpContext context, IDiagnosticInfo info) { if (!TryAuthorize(context)) { return(Task.CompletedTask); } var responseBody = Encoding.UTF8.GetBytes(ComposeListPage(context, info)); context.Response.StatusCode = 200; context.Response.ContentLength = responseBody.Length; context.Response.ContentType = "text/html"; DisableResponseCaching(context); return(context.Response.Body.WriteAsync(responseBody, 0, responseBody.Length)); }
private string ComposeListPage(HttpContext context, IDiagnosticInfo info) { var builder = new StringBuilder(); foreach (var group in info.ListAll() .GroupBy(entry => entry.Component, StringComparer.OrdinalIgnoreCase) .OrderBy(group => group.Key)) { builder.AppendLine($"<h2>{group.Key}</h2>"); builder.AppendLine("<ul>"); foreach (var entry in group.OrderBy(entry => entry.Name, StringComparer.OrdinalIgnoreCase)) { builder.AppendLine($"<li><a href=\"{CreateInfoUrl(entry)}\">{entry.Name}</a></li>"); } builder.AppendLine("</ul>"); builder.AppendLine("<br/>"); } return(builder.ToString()); }
/// <summary> /// Adds a <see cref="IDiagnosticInfo"/> to this <see cref="Diagnostics"/>. /// </summary> /// <param name="info">The <see cref="IDiagnosticInfo"/> to add.</param> /// <returns>This instance to chain calls.</returns> public Diagnostics WithInfo(IDiagnosticInfo info) { this.Information.Add(info); return(this); }
/// <summary> /// Writes <see cref="IDiagnosticInfo" /> using the provided encoder <see cref="IBinaryEncoder" />. /// </summary> /// <param name="encoder">The encoder - an object implementing the <see cref="IBinaryEncoder" /> interface.</param> /// <param name="value">The value to be encoded.</param> public abstract void Write(IBinaryEncoder encoder, IDiagnosticInfo value);
public void Write(IBinaryEncoder encoder, IDiagnosticInfo value) { _encoder.Write(this, value); }
public override void Write(IBinaryEncoder encoder, IDiagnosticInfo value) { throw new NotImplementedException(); }