Exemplo n.º 1
0
        public void Read(Stream input)
        {
            if (input.ReadValueU8() != 0x80)
            {
                throw new InvalidDataException("not a binary XML file");
            }

            var stringTable = new BinaryXmlStringTable();

            stringTable.Read(input);

            this.Root = new BinaryXmlNode();
            this.Root.Read(input, stringTable);
        }
Exemplo n.º 2
0
        public void Read(Stream input, BinaryXmlStringTable stringTable)
        {
            this.Name = stringTable[input.ReadValuePackedS32()];
            this.Attributes.Clear();
            this.Children.Clear();
            this.Value = null;

            byte flags = input.ReadValueU8();

            // Value
            if ((flags & 1) == 1)
            {
                this.Value = stringTable[input.ReadValuePackedS32()];
            }

            // Attributes
            if ((flags & 2) == 2)
            {
                int count = input.ReadValuePackedS32();
                for (int i = 0; i < count; i++)
                {
                    var key   = stringTable[input.ReadValuePackedS32()];
                    var value = stringTable[input.ReadValuePackedS32()];
                    this.Attributes[key] = value;
                }
            }

            // Children
            if ((flags & 4) == 4)
            {
                int count = input.ReadValuePackedS32();
                for (int i = 0; i < count; i++)
                {
                    var child = new BinaryXmlNode();
                    child.Read(input, stringTable);
                    this.Children.Add(child);
                }
            }
        }