Exemple #1
0
 public IServiceDependencies Create(IOwinContext context, Action <IOwinContext, Func <string> > trace)
 {
     return(new ServiceDependencies(
                _renderContextFactory.Create(trace),
                AssetManager,
                NameManager)
            .Initialize(context));
 }
        public IPageDependencies Create(IOwinContext context, Action <IOwinContext, Func <string> > trace)
        {
            var renderContext = _renderContextFactory.Create(trace);

            return(new PageDependencies(
                       renderContext,
                       _assetManager,
                       _nameManager)
                   .Initialize(context));
        }
        public IPackageDependencies Create(IOwinContext context, Action <IOwinContext, Func <string> > trace)
        {
            var renderContext = _renderContextFactory.Create(trace);

            return(new PackageDependencies(
                       renderContext,
                       _assetManager,
                       _nameManager,
                       _moduleDependenciesFactory,
                       _pageDependenciesFactory,
                       _layoutDependenciesFactory,
                       _regionDependenciesFactory,
                       _componentDependenciesFactory,
                       _dataProviderDependenciesFactory)
                   .Initialize(context));
        }
        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);
                }
            }
        }