Esempio n. 1
0
        List <DiagnosticsNode> _getChildrenFiltered(DiagnosticsNode node,
                                                    _SerializeConfig config)
        {
            var children = new List <DiagnosticsNode>();

            foreach (var child in node.getChildren())
            {
                if (!config.summaryTree || this._shouldShowInSummaryTree(child))
                {
                    children.Add(child);
                }
                else
                {
                    children.AddRange(this._getChildrenFiltered(child, config));
                }
            }

            return(children);
        }
Esempio n. 2
0
 public static _SerializeConfig merge(_SerializeConfig from, int?subtreeDepth = null,
                                      List <Diagnosticable> pathToInclude     = null)
 {
     return(new _SerializeConfig(from.groupName, from.summaryTree, subtreeDepth ?? from.subtreeDepth,
                                 pathToInclude ?? from.pathToInclude, from.includeProperties, from.expandPropertyValues));
 }
Esempio n. 3
0
        List <Dictionary <string, object> > _nodesToJson(List <DiagnosticsNode> nodes, _SerializeConfig config)
        {
            if (nodes == null)
            {
                return(new List <Dictionary <string, object> >());
            }

            return(nodes.Select(node => {
                if (config.pathToInclude != null && config.pathToInclude.Count > 0)
                {
                    if (config.pathToInclude[0] == node.valueObject)
                    {
                        return this._nodeToJson(node, _SerializeConfig.merge(config,
                                                                             pathToInclude: config.pathToInclude.GetRange(1, config.pathToInclude.Count - 1)));
                    }
                    else
                    {
                        return this._nodeToJson(node, _SerializeConfig.merge(config));
                    }
                }

                return this._nodeToJson(node,
                                        config.summaryTree || config.subtreeDepth > 1 || this._shouldShowInSummaryTree(node)
                        ? _SerializeConfig.merge(config, subtreeDepth: config.subtreeDepth - 1)
                        : config
                                        );
            }).ToList());
        }
Esempio n. 4
0
        Dictionary <string, object> _nodeToJson(DiagnosticsNode node, _SerializeConfig config)
        {
            if (node == null)
            {
                return(null);
            }

            var ret   = node.toJsonMap();
            var value = node.valueObject;

            ret["objectId"] = this.toId(node, config.groupName);
            ret["valueId"]  = this.toId(value, config.groupName);

            if (config.summaryTree)
            {
                ret["summaryTree"] = config.summaryTree;
            }

            var createdByLocalProject = true; // todo;

            if (config.subtreeDepth > 0 || (config.pathToInclude != null && config.pathToInclude.Count > 0))
            {
                ret["children"] = this._nodesToJson(this._getChildrenFiltered(node, config), config);
            }

            if (config.includeProperties)
            {
                ret["properties"] = this._nodesToJson(
                    node.getProperties().Where((n) =>
                                               !n.isFiltered(createdByLocalProject ? DiagnosticLevel.fine : DiagnosticLevel.info)).ToList(),
                    new _SerializeConfig(groupName: config.groupName, subtreeDepth: 1, expandPropertyValues: true)
                    );
            }

            var typeDef  = typeof(DiagnosticsProperty <>);
            var nodeType = node.GetType();

            if (nodeType.IsGenericType && nodeType.GetGenericTypeDefinition() == typeDef)
            {
                if (value is Color)
                {
                    ret["valueProperties"] = new Dictionary <string, object> {
                        { "red", ((Color)value).red },
                        { "green", ((Color)value).green },
                        { "blue", ((Color)value).blue },
                        { "alpha", ((Color)value).alpha },
                    };
                }
                else if (value is IconData)
                {
                    ret["valueProperties"] = new Dictionary <string, object> {
                        { "codePoint", ((IconData)value).codePoint }
                    };
                }

                if (config.expandPropertyValues && value is Diagnosticable)
                {
                    ret["properties"] = this._nodesToJson(
                        ((Diagnosticable)value).toDiagnosticsNode().getProperties()
                        .Where(n => !n.isFiltered(DiagnosticLevel.info)).ToList(),
                        new _SerializeConfig(groupName: config.groupName, subtreeDepth: 0, expandPropertyValues: false)
                        );
                }
            }

            return(ret);
        }