Exemplo n.º 1
0
        public override sealed bool ParseData(byte[] buffer)
        {
            if ((buffer == null))
            {
                return(false);
            }
            int offset = 0;

            StringsHeader stringsHeader = FileTools.ByteArrayToStructure <StringsHeader>(buffer, ref offset);

            for (int i = 0; i < stringsHeader.Count; i++)
            {
                StringBlock stringBlock = new StringBlock
                {
                    ReferenceId = FileTools.ByteArrayToInt32(buffer, ref offset),
                    Unknown     = FileTools.ByteArrayToInt32(buffer, ref offset)
                };

                int count = FileTools.ByteArrayToInt32(buffer, ref offset);
                stringBlock.StringId = FileTools.ByteArrayToStringASCII(buffer, offset);
                offset += count + 1;

                stringBlock.Reserved = FileTools.ByteArrayToInt32(buffer, ref offset);

                count = FileTools.ByteArrayToInt32(buffer, ref offset);
                stringBlock.String = FileTools.ByteArrayToStringUnicode(buffer, offset, count);
                offset            += count;

                int attributeCount = FileTools.ByteArrayToInt32(buffer, ref offset);

                for (int j = 0; j < attributeCount; j++)
                {
                    count = FileTools.ByteArrayToInt32(buffer, ref offset);
                    int byteCount = (count + 1) * 2;

                    switch (j)
                    {
                    case 0:
                        stringBlock.Attribute1 = FileTools.ByteArrayToStringUnicode(buffer, offset, byteCount);
                        break;

                    case 1:
                        stringBlock.Attribute2 = FileTools.ByteArrayToStringUnicode(buffer, offset, byteCount);
                        break;

                    case 2:
                        stringBlock.Attribute3 = FileTools.ByteArrayToStringUnicode(buffer, offset, byteCount);
                        break;

                    case 3:
                        stringBlock.Attribute4 = FileTools.ByteArrayToStringUnicode(buffer, offset, byteCount);
                        break;
                    }

                    offset += byteCount;
                }

                Rows.Add(stringBlock);
            }

            return(HasIntegrity = ((offset == buffer.Length)) ? true : false);
        }