Beispiel #1
0
        private void PopulateTreeView(XmlBinaryNode binaryNode)
        {
            TreeNode rootNode = this.tvBinaryFile.Nodes.Add(binaryNode.ToString(this.staticDictionary, this.readerSession, false));

            foreach (XmlBinaryNode child in binaryNode.Children)
            {
                AddTreeNode(rootNode, child);
            }
        }
Beispiel #2
0
        private void AddTreeNode(TreeNode rootNode, XmlBinaryNode node)
        {
            TreeNode childNode = rootNode.Nodes.Add(node.ToString(this.staticDictionary, this.readerSession, false));

            foreach (XmlBinaryNode child in node.Children)
            {
                this.AddTreeNode(childNode, child);
            }

            if (node.NodeType == XmlBinaryNodeType.Array)
            {
                Array elements = null;
                BinaryArrayElements arrayElements = node.ArrayElements;
                byte   nodeType     = arrayElements.NodeType;
                string nodeTypeName = XmlBinaryNodeType.GetNodeName((byte)(nodeType & 0xFE));
                switch (arrayElements.NodeType)
                {
                case XmlBinaryNodeType.Int16Text:
                case XmlBinaryNodeType.Int16TextWithEndElement:
                    elements = arrayElements.ShortArray;
                    break;

                case XmlBinaryNodeType.Int32Text:
                case XmlBinaryNodeType.Int32TextWithEndElement:
                    elements = arrayElements.IntArray;
                    break;

                case XmlBinaryNodeType.Int64Text:
                case XmlBinaryNodeType.Int64TextWithEndElement:
                    elements = arrayElements.LongArray;
                    break;

                case XmlBinaryNodeType.BoolText:
                case XmlBinaryNodeType.BoolTextWithEndElement:
                    elements = arrayElements.BoolArray;
                    break;

                case XmlBinaryNodeType.DateTimeText:
                case XmlBinaryNodeType.DateTimeTextWithEndElement:
                    elements = arrayElements.DateTimeArray;
                    break;

                case XmlBinaryNodeType.DecimalText:
                case XmlBinaryNodeType.DecimalTextWithEndElement:
                    elements = arrayElements.DecimalArray;
                    break;

                case XmlBinaryNodeType.DoubleText:
                case XmlBinaryNodeType.DoubleTextWithEndElement:
                    elements = arrayElements.DoubleArray;
                    break;

                case XmlBinaryNodeType.FloatText:
                case XmlBinaryNodeType.FloatTextWithEndElement:
                    elements = arrayElements.FloatArray;
                    break;

                case XmlBinaryNodeType.GuidText:
                case XmlBinaryNodeType.GuidTextWithEndElement:
                    elements = arrayElements.GuidArray;
                    break;

                case XmlBinaryNodeType.TimeSpanText:
                case XmlBinaryNodeType.TimeSpanTextWithEndElement:
                    elements = arrayElements.TimeSpanArray;
                    break;
                }

                if (elements != null)
                {
                    if (nodeTypeName.EndsWith("Text"))
                    {
                        nodeTypeName = nodeTypeName.Substring(0, nodeTypeName.Length - 4);
                    }

                    foreach (var item in elements)
                    {
                        rootNode.Nodes.Add(string.Format(CultureInfo.InvariantCulture, "({0}) {1}", nodeTypeName, item));
                    }
                }
            }
        }