private void EndIndent(IHtmlWriter html)
 {
     html.WriteCloseTag("span");
     html.WriteLine();
     html.WriteCloseTag("div");
     html.WriteLine();
 }
            public override void Write(IHtmlWriter writer)
            {
                if (string.IsNullOrEmpty(Name))
                {
                    writer.Write("function (");
                }
                else if (IsPublic)
                {
                    writer.Write("var ");
                    writer.Write(Name);
                    writer.Write(" = function (");
                }
                else
                {
                    writer.Write("function ");
                    writer.Write(Name);
                    writer.Write(" (");
                }

                if (!string.IsNullOrEmpty(Parameters))
                {
                    writer.Write(Parameters);
                }

                writer.WriteLine(") {");
                writer.IndentLevel++;

                foreach (var line in Body.Replace("\r", "").Split('\n'))
                {
                    writer.WriteLine(line);
                }

                writer.IndentLevel--;
                writer.WriteLine(string.IsNullOrEmpty(Name) ? "}();" : "}");
            }
 private void StartIndent(IHtmlWriter html, bool expanded)
 {
     html.WriteOpenTag("div", "class", "section");
     html.WriteLine();
     html.WriteElementLine("button", "+", "class", expanded ? "indent active": "indent");
     html.WriteOpenTag("span", "class", "indented");
     html.WriteLine();
 }
Beispiel #4
0
 public override void ToHtml(IHtmlWriter writer)
 {
     writer.Write(Selector);
     writer.Write(" { ");
     writer.Write(Styles);
     writer.WriteLine(" }");
 }
Beispiel #5
0
 public override void ToHtml(IHtmlWriter writer)
 {
     if (!string.IsNullOrEmpty(Text))
     {
         writer.Write(Text);
         writer.WriteLine();
     }
 }
        private void WriteHtml(IHtmlWriter html, DebugRegion region, int depth)
        {
            if (region.Element != null)
            {
                html.WriteElementLine("p", "zone inherits from '" + region.Element.Name + "' region");
                if (depth != 1)
                {
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Element.GetDebugInfo(), 2);
                    EndIndent(html);
                }
            }

            if (region.RepeatType != null)
            {
                html.WriteOpenTag("p");
                html.WriteText("Repeat region for each ");
                html.WriteElement("i", region.RepeatType.DisplayName());
                if (!string.IsNullOrEmpty(region.RepeatScope))
                {
                    html.WriteText(" in '" + region.RepeatScope + "' scope");
                }
                html.WriteText(" from ");
                html.WriteElement("i", region.ListType.DisplayName());
                if (!string.IsNullOrEmpty(region.ListScope))
                {
                    html.WriteText(" in '" + region.ListScope + "' scope");
                }
                html.WriteCloseTag("p");
                html.WriteLine();
            }

            if (region.Scope != null)
            {
                if (region.Scope.Scopes != null)
                {
                    html.WriteElementLine("p", "zone data scope");
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Scope, 3);
                    EndIndent(html);
                }
            }

            if (region.Children != null && region.Children.Count > 0)
            {
                html.WriteElementLine("p", "zone has contents");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, region.Children[0], depth - 1);
                    EndIndent(html);
                }
            }
        }
            public override void Write(IHtmlWriter writer)
            {
                if (string.IsNullOrEmpty(Name))
                {
                    throw new Exception("You can not add a JavaScript class with no name");
                }

                writer.Write("var ");
                writer.Write(Name);
                writer.WriteLine(" = function () {");
                writer.IndentLevel++;

                foreach (var line in Body.Replace("\r", "").Split('\n'))
                {
                    writer.WriteLine(line);
                }

                writer.IndentLevel--;
                writer.WriteLine("}();");
            }
 public override void Write(IHtmlWriter writer)
 {
     if (string.IsNullOrEmpty(Name))
     {
         if (!string.IsNullOrEmpty(InitializationExpression))
         {
             writer.Write(InitializationExpression);
         }
     }
     else
     {
         writer.Write(string.IsNullOrEmpty(Type) ? "var" : Type);
         writer.Write(' ');
         writer.Write(Name);
         if (!string.IsNullOrEmpty(InitializationExpression))
         {
             writer.Write(" = ");
             writer.Write(InitializationExpression);
         }
     }
     writer.WriteLine(";");
 }
            public void Write(IHtmlWriter writer)
            {
                if (_elements == null)
                {
                    return;
                }

                var hasNamespace = !string.IsNullOrEmpty(NamespaceName);

                if (hasNamespace)
                {
                    writer.Write(Line1());
                    writer.Write(Line2());
                    writer.IndentLevel++;
                }

                foreach (var element in _elements)
                {
                    writer.WriteLine();
                    element.Write(writer);
                }

                if (hasNamespace)
                {
                    writer.WriteLine();

                    foreach (var element in _elements.Where(e => e.IsPublic && !string.IsNullOrEmpty(e.Name)))
                    {
                        writer.WriteLine("exported." + element.Name + " = " + element.Name + ";");
                    }

                    writer.IndentLevel--;
                    writer.WriteLine(LineN2());
                    writer.WriteLine(LineN1());
                    writer.WriteLine();
                }
            }
        private void WriteHtml(IHtmlWriter html, DebugPage page, int depth)
        {
            if (page.Routes != null && page.Routes.Count > 0)
            {
                html.WriteElementLine("h3", "Page routes");
                foreach (var route in page.Routes)
                {
                    html.WriteElementLine("p", "Route: " + route);
                }
            }

            if (page.Scope != null)
            {
                html.WriteElementLine("p", "Page has a data scope");
                StartIndent(html, true);
                WriteDebugInfo(html, page.Scope, depth - 1);
                EndIndent(html);
            }

            if (page.DataContext != null)
            {
                html.WriteElementLine("p", "Page has a data context");
                StartIndent(html, true);
                WriteDebugInfo(html, page.DataContext, depth - 1);

                var dataContextBuilder = page.DataContext.Instance as IDataContextBuilder;
                if (dataContextBuilder != null)
                {
                    DebugRenderContext debugRenderContext;
                    try
                    {
                        var renderContext = _renderContextFactory.Create((c, f) => { });
                        dataContextBuilder.SetupDataContext(renderContext);
                        debugRenderContext = renderContext.GetDebugInfo <DebugRenderContext>();
                    }
                    catch (Exception ex)
                    {
                        debugRenderContext = null;
                        html.WriteElementLine("p", "Exception thrown when constructing data context tree: " + ex.Message);
                        if (!string.IsNullOrEmpty(ex.StackTrace))
                        {
                            html.WriteOpenTag("pre");
                            html.WriteLine();
                            html.WritePreformatted(ex.StackTrace);
                            html.WriteLine();
                            html.WriteCloseTag("pre");
                            html.WriteLine();
                        }
                    }

                    WriteHtml(html, debugRenderContext, depth - 1);
                }

                EndIndent(html);
            }

            if (page.Layout != null)
            {
                html.WriteElementLine("p", "Page has a layout");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, page.Layout, depth - 1);
                    EndIndent(html);
                }
            }
        }
        private void WriteHtml(IHtmlWriter html, DebugDataScopeRules dataScopeProvider, int depth)
        {
            if (depth == 1)
            {
                return;
            }

            if (dataScopeProvider.Scopes != null && dataScopeProvider.Scopes.Count > 0)
            {
                html.WriteElementLine("p", "Dependencies resolved in this scope");
                html.WriteOpenTag("ul");
                html.WriteLine();
                foreach (var scope in dataScopeProvider.Scopes)
                {
                    html.WriteElementLine("li", scope.ToString());
                }
                html.WriteCloseTag("ul");
                html.WriteLine();
            }

            if (dataScopeProvider.DataSupplies != null && dataScopeProvider.DataSupplies.Count > 0)
            {
                html.WriteElementLine("p", "Data supplied in this scope");
                html.WriteOpenTag("ul");
                html.WriteLine();
                foreach (var dataSupplier in dataScopeProvider.DataSupplies)
                {
                    html.WriteElementLine("li", dataSupplier.ToString().InitialCaps());
                }
                html.WriteCloseTag("ul");
                html.WriteLine();
            }

            if (dataScopeProvider.Parent != null)
            {
                if (depth == 1)
                {
                    html.WriteElementLine("p", "Has a parent scope");
                }
                else
                {
                    html.WriteElementLine("p", "Parent scope");
                    StartIndent(html, true);
                    WriteDebugInfo(html, dataScopeProvider.Parent, depth - 1);
                    EndIndent(html);
                }
            }

            if (dataScopeProvider.Children != null && dataScopeProvider.Children.Count > 0)
            {
                if (depth == 1)
                {
                    html.WriteElementLine("p", "Has " + dataScopeProvider.Children.Count + " child scopes");
                }
                else
                {
                    html.WriteElementLine("p", "Child scopes");
                    StartIndent(html, false);
                    foreach (var child in dataScopeProvider.Children)
                    {
                        WriteDebugInfo(html, child, depth - 1);
                    }
                    EndIndent(html);
                }
            }
        }
        private void WriteDebugInfo(IHtmlWriter html, DebugInfo debugInfo, int depth)
        {
            if (depth == 0)
            {
                return;
            }

            html.WriteElementLine("h2", debugInfo.Type + " '" + debugInfo.Name + "'");
            if (debugInfo.Instance != null)
            {
                html.WriteOpenTag("p");
                html.WriteElementLine("i", debugInfo.Instance.GetType().DisplayName());
                html.WriteCloseTag("p");
                html.WriteLine();
            }

            if (debugInfo.DataConsumer != null)
            {
                var consumerDescription = debugInfo.DataConsumer.ToString();
                var lines = consumerDescription.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                if (lines.Length > 0)
                {
                    html.WriteElementLine("p", "Is a data consumer");
                    html.WriteOpenTag("ul");
                    html.WriteLine();
                    foreach (var line in lines)
                    {
                        html.WriteElementLine("li", line.InitialCaps());
                    }
                    html.WriteCloseTag("ul");
                    html.WriteLine();
                }
            }

            if (debugInfo.DependentComponents != null && debugInfo.DependentComponents.Count > 0)
            {
                html.WriteElementLine("p", "Dependent components");
                html.WriteOpenTag("ul");
                html.WriteLine();
                foreach (var component in debugInfo.DependentComponents)
                {
                    html.WriteElementLine("li", component.GetDebugInfo(0, 0).ToString().InitialCaps());
                }
                html.WriteCloseTag("ul");
                html.WriteLine();
            }

            if (debugInfo is DebugComponent)
            {
                WriteHtml(html, (DebugComponent)debugInfo, depth);
            }
            if (debugInfo is DebugDataContext)
            {
                WriteHtml(html, (DebugDataContext)debugInfo, depth);
            }
            if (debugInfo is DebugDataProvider)
            {
                WriteHtml(html, (DebugDataProvider)debugInfo, depth);
            }
            if (debugInfo is DebugDataScopeRules)
            {
                WriteHtml(html, (DebugDataScopeRules)debugInfo, depth);
            }
            if (debugInfo is DebugLayout)
            {
                WriteHtml(html, (DebugLayout)debugInfo, depth);
            }
            if (debugInfo is DebugModule)
            {
                WriteHtml(html, (DebugModule)debugInfo, depth);
            }
            if (debugInfo is DebugPackage)
            {
                WriteHtml(html, (DebugPackage)debugInfo, depth);
            }
            if (debugInfo is DebugPage)
            {
                WriteHtml(html, (DebugPage)debugInfo, depth);
            }
            if (debugInfo is DebugRegion)
            {
                WriteHtml(html, (DebugRegion)debugInfo, depth);
            }
            if (debugInfo is DebugRenderContext)
            {
                WriteHtml(html, (DebugRenderContext)debugInfo, depth);
            }
            if (debugInfo is DebugRoute)
            {
                WriteHtml(html, (DebugRoute)debugInfo, depth);
            }
            if (debugInfo is DebugService)
            {
                WriteHtml(html, (DebugService)debugInfo, depth);
            }
        }
 public override void Write(IHtmlWriter writer)
 {
     writer.Write(Text);
     writer.WriteLine();
 }