public HtmlDocument Write() { HtmlTag header = new HtmlTag("div", x => { var table = x.Add <TableTag>() .AddBodyRow(row => { row.Cell("Request Url:"); row.Cell(_report.Url).AddClass("cell-data"); }) .AddBodyRow(row => { row.Cell("Execution Time:"); row.Cell(_report.ExecutionTime + " milliseconds"); }) .AddBodyRow(row => { row.Cell("At:"); row.Cell(_report.Time.ToString("G")); }); table.AddClass("summary"); writeFormData(x); }); var reportWriter = new DebugReportTagWriter(); _report.Steps.Each(reportWriter.WriteStep); string title = "Debug Run of " + _report.Url; return(DiagnosticHtml.BuildDocument(_urls, title, header, reportWriter.Tag)); }
public HtmlDocument Html() { var tags = new List <HtmlTag> { showIntro() }; IEnumerable <Type> ignoredModels = new[] { typeof(RenderHtmlDocumentNode), typeof(RenderHtmlTagNode), typeof(RenderJsonNode) }; var table = BehaviorGraphWriter.WriteBehaviorChainTable(_behaviorGraph.Behaviors .Where(b => b.HasOutputBehavior() && !b.ActionOutputType().IsSimple()) .Where(b => b.Outputs.Select(o => o.GetType()).Except(ignoredModels).Any()) .OrderBy(b => b.RoutePattern), new RouteColumn(), new OutputModelColumn(_examplePageUrl), new OutputColumn()); tags.Add(table); var doc = DiagnosticHtml.BuildDocument(_urlRegistry, "FubuMVC.UI Examples", tags.ToArray()); doc.AddStyle(DiagnosticHtml.GetResourceText(GetType(), "examples.css")); return(doc); }
public HtmlDocument Example(ExampleHtmlRequest exampleHtmlRequest) { var modelPath = exampleHtmlRequest.Model ?? typeof(ExampleViewModel).FullName + "-Person"; var tags = new List <HtmlTag>(); var propertyPath = new List <string>(modelPath.Split('-')); var rootModelTypeName = propertyPath[0]; tags.Add(new HtmlTag("h3").AddClass("viewmodel").Text(propertyPath.Join("."))); propertyPath.RemoveAt(0); Type scannedModelType = getTypeFromName(rootModelTypeName); var scannedModelInstance = createInstance(scannedModelType); var tagGeneratorType = typeof(TagGenerator <>).MakeGenericType(scannedModelType); var tagGenerator = (ITagGenerator)_serviceLocator.GetInstance(tagGeneratorType); tagGenerator.SetModel(scannedModelInstance); var propertyChainParts = new List <PropertyInfo>(); while (propertyPath.Count > 0) { var parentPropertyInfo = scannedModelType.GetProperty(propertyPath[0]); propertyChainParts.Add(parentPropertyInfo); var currentModelType = parentPropertyInfo.PropertyType; var currentModel = createInstance(currentModelType); setProperty(parentPropertyInfo, scannedModelInstance, currentModel); scannedModelType = currentModelType; scannedModelInstance = currentModel; propertyPath.RemoveAt(0); } var modelProperties = scannedModelType.GetProperties(); var propertiesToLink = modelProperties.Where(p => !TypeDescriptor.GetConverter(p.PropertyType).CanConvertFrom(typeof(string))); var propertiesToShow = modelProperties.Except(propertiesToLink); // show links to deeper properties var linkList = new HtmlTag("ul").AddClass("subproperties"); foreach (var propertyInfo in propertiesToLink) { var linkTag = new LinkTag("", _examplePageUrl + "?model=" + modelPath + "-" + propertyInfo.Name); linkTag.Append(new HtmlTag("code").Text(getPropertySourceCode(propertyInfo))); var listItem = new HtmlTag("li").Append(linkTag); linkList.Append(listItem); } if (linkList.Children.Count > 0) { tags.Add(linkList); } // show examples populateInstance(scannedModelInstance, propertiesToShow); foreach (var propertyInfo in propertiesToShow) { var property = propertyChainParts.Count > 0 ? (Accessor) new PropertyChain(propertyChainParts.Concat(new[] { propertyInfo }).Select(x => new PropertyValueGetter(x)).ToArray()) : new SingleProperty(propertyInfo); var propertyExpression = "x => x." + property.PropertyNames.Join("."); var propertySource = getPropertySourceCode(propertyInfo); var example = new HtmlTag("div").AddClass("example"); example.Append(new HtmlTag("code").AddClass("property").Text(propertySource)); example.Append(createExample(tagGenerator.LabelFor(tagGenerator.GetRequest(property)), "LabelFor({0})".ToFormat(propertyExpression))); example.Append(createExample(tagGenerator.DisplayFor(tagGenerator.GetRequest(property)), "DisplayFor({0})".ToFormat(propertyExpression))); example.Append(createExample(tagGenerator.InputFor(tagGenerator.GetRequest(property)), "InputFor({0})".ToFormat(propertyExpression))); tags.Add(example); } var doc = DiagnosticHtml.BuildDocument(_urlRegistry, "FubuMVC.UI Examples", tags.ToArray()); doc.AddStyle(DiagnosticHtml.GetResourceText(GetType(), "examples.css")); return(doc); }
public static HtmlDocument Write(IEnumerable <LogEntry> entries, string title) { var tags = createTags(entries); return(DiagnosticHtml.BuildDocument(null, title, tags.ToArray())); }