void ExplainStruct(WebData data, Type t) { var html = new HtmlPageBuilder(data.Request); html.Breadcrump.Add(new WebLink() { Text = t.FullName }); Bootstrap4 content = html.Content; var layout = RowLayout.CreateTyped(t); content.CardOpen($"<h2>Struct {t.Name}<h2><h4>Table {layout.Name}</h4>{layout.FieldCount} Fields, {t.AssemblyQualifiedName}"); DocumentHtml(content, documentation.GetType(t), t.ToString()); content.ListGroupOpen(); int i = 0; foreach (FieldProperties field in layout.Fields) { XNetDocItem doc = documentation.GetField(t, field.Name.ToString()); FieldHtml(content, i++, field, doc); } content.ListGroupClose(); content.CardClose(); content.AddHtml(" "); var message = WebMessage.Create("Explain " + t.Name, string.Format("Explain struct {0}", t.Name)); data.Answer = html.ToAnswer(message); }
void ExplainFunction(WebData data, WebServerMethod function) { var html = new HtmlPageBuilder(data.Request); { string path = string.Empty; string[] parts = function.FullPaths.First().Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int last = parts.Length - 1; for (int n = 0; n < parts.Length; n++) { path += "/" + parts[n]; html.Breadcrump.Add(new WebLink() { Text = parts[n], Link = (n != last) ? $"/Explain?functions={path}" : $"/Explain?function={path}" }); } } Bootstrap4 content = html.Content; WebServerAuthType authType = function.PageAttribute?.AuthType ?? WebServerAuthType.None; { string link = function.FullPaths.First(); var head = new Bootstrap4(); if (authType != WebServerAuthType.None) { // head.DivOpen(Bootstrap4.Item.float_right); head.DivOpen(Bootstrap4.Item.float_right); AddBadges(head, function.PageAttribute); head.DivClose(Bootstrap4.Item.float_right); // head.AddHtml("<br/>"); } head.AddHtml("<h2>"); head.AddHtml(function.Method.Name.SplitCamelCase().Join(" ")); if (function.Parameters.Length > 0) { head.AddHtml(" ("); head.AddHtml(function.ParameterString()); head.AddHtml(")"); } head.AddHtml("</h2>"); head.DivOpen(Bootstrap4.Item.float_right); head.Link("html", link + ".html", "btn btn-sm btn-outline-primary"); head.Link("json", link + ".json", "btn btn-sm btn-outline-primary"); head.Link("xml", link + ".xml", "btn btn-sm btn-outline-primary"); head.Link("plain", link + ".txt", "btn btn-sm btn-outline-primary"); head.DivClose(Bootstrap4.Item.float_right); head.AddHtml(function.Method.DeclaringType.AssemblyQualifiedName); content.CardOpen(head.ToString()); } XNetDocItem doc = documentation.GetMethod(function.Method); DocumentHtml(content, doc, function.IsAction ? "Generic action" : function.Method.ToString()); content.ListGroupOpen(); int i = 0; foreach (ParameterInfo parameter in function.Parameters) { if (parameter.ParameterType == typeof(WebData)) { continue; } ParameterHtml(content, i++, parameter, doc); } content.ListGroupClose(); content.CardClose(); content.AddHtml(" "); var message = WebMessage.Create("Explain " + function.Name, string.Format("Explain function {0}", function)); data.Answer = html.ToAnswer(message); }