Exemple #1
0
        TreeNode CreateTreeNodeCore(bool displayUnsetFields)
        {
            var configuration = new TreeNodeObjectExplorerConfiguration {
                ShowUnsetFields = displayUnsetFields
            };

            using var stream = item.OpenStream();

            var rawEMsg = PeekUInt(stream);
            var node    = BuildInfoNode(rawEMsg);

            node.Expand();

            var header = ReadHeader(rawEMsg, stream);

            node.Nodes.Add(new TreeNodeObjectExplorer("Header", header, configuration).TreeNode);

            var body     = ReadBody(rawEMsg, stream, header);
            var bodyNode = new TreeNodeObjectExplorer("Body", body, configuration).TreeNode;

            node.Nodes.Add(bodyNode);

            var payload = ReadPayload(stream);

            if (payload != null && payload.Length > 0)
            {
                node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode);
            }

            if (Specializations != null)
            {
                var objectsToSpecialize = new[] { body };
                while (objectsToSpecialize.Any())
                {
                    var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o)));

                    if (!specializations.Any())
                    {
                        break;
                    }

                    bodyNode.Collapse(ignoreChildren: true);

                    var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value, configuration).TreeNode).ToArray();
                    node.Nodes.AddRange(extraNodes);

                    // Let the specializers examine any new message objects.
                    objectsToSpecialize = specializations.Select(x => x.Value).ToArray();
                }
            }

            return(node);
        }
        public void CreateTreeNode()
        {
            Node = new TreeNode();

            using (var stream = item.OpenStream())
            {
                var rawEMsg = PeekUInt(stream);

                Node.Nodes.Add(BuildInfoNode(rawEMsg));

                var header = ReadHeader(rawEMsg, stream);
                Node.Nodes.Add(BuildHeaderNode(header));

                var body = ReadBody(rawEMsg, stream, header);
                Node.Nodes.Add(BuildBodyNode(body));

                var payload = ReadPayload(stream);
                if (payload != null && payload.Length > 0)
                {
                    Node.Nodes.Add(BuildPayloadNode(payload));
                }

                var nodeCount = Node.Nodes.Count;
                BuildSpecializations(body);

                var hasSpecializations = Node.Nodes.Count > nodeCount;
                if (hasSpecializations)
                {
                    // Hide the 'normal' nodes
                    for (int i = 0; i < nodeCount; i++)
                    {
                        var node = Node.Nodes[i];
                        SetNodeExpandByDefault(node, false);
                    }
                }
            }
        }