public void Deserialize(Stream input)
        {
            if (input.ReadValueU8() != 0)
            {
                throw new FormatException("not an xml resource file");
            }
            var endian = Endian.Little;

            this.Unknown1 = input.ReadValueU8();
            var stringTableSize     = ReadValuePackedU32(input, endian);
            var totalNodeCount      = ReadValuePackedU32(input, endian);
            var totalAttributeCount = ReadValuePackedU32(input, endian);

            uint actualNodeCount = 1, actualAttributeCount = 0;

            this.Root = new Node();
            this.Root.Deserialize(
                input, ref actualNodeCount, ref actualAttributeCount, endian);

            if (actualNodeCount != totalNodeCount ||
                actualAttributeCount != totalAttributeCount)
            {
                throw new FormatException("count mismatch");
            }

            var stringTableData = new byte[stringTableSize];

            input.Read(stringTableData, 0, stringTableData.Length);
            var stringTable = new StringTable();

            stringTable.Deserialize(stringTableData);

            this.Root.ReadStringTable(stringTable);
        }
        public void Deserialize(BinaryReader reader)
        {
            int num = reader.ReadInt32();

            if (num == 5)
            {
                nextNoteId = reader.ReadInt32();
                stringTable.Deserialize(reader);
                noteEntries.Deserialize(reader);
            }
        }
Esempio n. 3
0
        internal bool Deserialize(IReader reader)
        {
            if (!reader.ReadFourBytes("loxx"))
            {
                return(false);
            }
            int version = reader.Read7BitInt();

            SizeCode = reader.Read7BitInt();
            if (SizeCode > 0)
            {
                _Code = reader.ReadBytes(SizeCode);
            }
            SizeConstant = reader.Read7BitInt();
            if (SizeConstant > 0)
            {
                _Constants = new ulong[SizeConstant];
                for (int i = 0; i < SizeConstant; i++)
                {
                    _Constants[i] = (ulong)reader.ReadLong();
                }
            }
            Strings.Deserialize(reader);
            int linesLength = reader.Read7BitInt();

            if (linesLength > 0)
            {
                _Lines = new ushort[linesLength];
                for (int i = 0; i < linesLength; i++)
                {
                    _Lines[i] = (ushort)reader.Read7BitInt();
                }
            }
            if (reader.ReadFourBytes("rule"))
            {
                Rules = new Rule[reader.Read7BitInt()];
                for (int i = 0; i < Rules.Length; i++)
                {
                    Rules[i] = Rule.Deserialize(reader);
                }
            }
            return(true);
        }