示例#1
0
        T IDebuggable.GetDebugInfo <T>(int parentDepth, int childDepth)
        {
            var debug = new DebugDataScopeRules
            {
                Instance = this,
                Name     = "data scope rules for " + ElementName,
            };

            lock (_lock)
            {
                debug.Scopes = DataScopes
                               .Select(s => new DebugDataScope {
                    DataType = s.DataType, ScopeName = s.ScopeName
                })
                               .ToList();

                debug.DataSupplies = SuppliedDependencies
                                     .Select(suppliedDependency =>
                                             new DebugSuppliedDependency
                {
                    Supplier = suppliedDependency.Item1.GetDebugInfo <DebugDataSupplier>(),

                    DataTypeSupplied = suppliedDependency.Item2 == null
                                ? null
                                : new DebugDataScope
                    {
                        DataType  = suppliedDependency.Item2.DataType,
                        ScopeName = suppliedDependency.Item2.ScopeName
                    }
                })
                                     .ToList();
            }

            return(debug as T);
        }
示例#2
0
        T IDebuggable.GetDebugInfo <T>(int parentDepth, int childDepth)
        {
            var debugInfo = new DebugDataScopeRules
            {
                Instance = this,
                Name     = "Data context builder #" + Id,
                Type     = "Data context builder"
            };

            if (_dataScopes != null && _dataScopes.Count > 0)
            {
                debugInfo.Scopes = _dataScopes
                                   .Select(s => new DebugDataScope
                {
                    DataType  = s.DataType,
                    ScopeName = s.ScopeName
                })
                                   .ToList();
            }

            if (_suppliedDependencies != null && _suppliedDependencies.Count > 0)
            {
                debugInfo.DataSupplies = _suppliedDependencies
                                         .Select(ds => new DebugSuppliedDependency
                {
                    Supplier         = ds.DataSupplier.GetDebugInfo <DebugDataSupplier>(),
                    DataSupply       = ds.DataSupply.GetDebugInfo <DebugDataSupply>(),
                    DataTypeSupplied = ds.DataDependency == null ? null : ds.DataDependency.GetDebugInfo <DebugDataScope>()
                })
                                         .ToList();
            }

            //if (_dataSupplies != null && _dataSupplies.Count > 0)
            //{
            //}

            if (_parent != null && parentDepth != 0)
            {
                debugInfo.Parent = _parent.GetDebugInfo <T>(parentDepth - 1, 0);
            }

            if (_children != null && _children.Length > 0 && childDepth != 0)
            {
                debugInfo.Children = _children
                                     .Select(c => c.GetDebugInfo <T>())
                                     .Cast <DebugInfo>()
                                     .ToList();
            }

            return(debugInfo as T);
        }
示例#3
0
        public DataScopeRulesDrawing(
            IDebugDrawing drawing,
            DrawingElement page,
            DebugDataScopeRules debugDataScope,
            int headingLevel,
            bool showButtons,
            int depth)
            : base(
                page,
                debugDataScope.Name,
                headingLevel)
        {
            CssClass = "data-scope";

            var details = new List <string>();

            AddDebugInfo(details, debugDataScope);

            if (details.Count > 0)
            {
                if (showButtons)
                {
                    AddDetails(details, AddHeaderButton(page, "Detail"));
                }
                else
                {
                    AddDetails(details, this);
                }
            }

            if (!ReferenceEquals(debugDataScope.Scopes, null) && debugDataScope.Scopes.Count > 0)
            {
                var scopeList = new TitledListDrawing(
                    "Data scopes",
                    debugDataScope.Scopes.Select(s => s.ToString().InitialCaps()));
                AddChild(scopeList);
            }

            if (!ReferenceEquals(debugDataScope.DataSupplies, null) && debugDataScope.DataSupplies.Count > 0)
            {
                AddChild(new TextDrawing
                {
                    CssClass = "h3",
                    Text     = new[] { "Data supplied" }
                });

                foreach (var supply in debugDataScope.DataSupplies)
                {
                    AddChild(new SuppliedDependencyDrawing(supply));
                }
            }

            if (depth != 0 && debugDataScope.Children != null && debugDataScope.Children.Count > 0)
            {
                foreach (var child in debugDataScope.Children)
                {
                    if (child.HasData())
                    {
                        var childDrawing = new DataScopeRulesDrawing(
                            drawing,
                            page,
                            child as DebugDataScopeRules,
                            headingLevel,
                            showButtons,
                            depth - 1);
                        AddChild(childDrawing);
                    }
                }
            }
        }
        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);
                }
            }
        }