Exemplo n.º 1
0
            /// <summary>
            /// Default ctor
            /// </summary>
            internal Package(Table table, ResReader reader)
                : base(reader, ChunkTypes.RES_TABLE_PACKAGE_TYPE)
            {
                this.table = table;

                id   = reader.ReadInt32();
                name = reader.ReadFixedLenghtUnicodeString(128);
                var typeStringsOffset = reader.ReadInt32();
                var lastPublicType    = reader.ReadInt32();
                var keyStringsOffset  = reader.ReadInt32();
                var lastPublicKey     = reader.ReadInt32();

                // Record offset
                var dataOffset = reader.Position;

                // Data
                typeStrings = new StringPool(reader);
                keyStrings  = new StringPool(reader);

                TypeSpec currentTypeSpec = null;

                while (reader.Position - dataOffset < DataSize)
                {
                    var chunkType = reader.PeekChunkType();
                    if (chunkType == ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE)
                    {
                        currentTypeSpec = Read(reader, () => new TypeSpec(this, reader));
                        typeSpecs.Add(currentTypeSpec);
                    }
                    else if (chunkType == ChunkTypes.RES_TABLE_TYPE_TYPE)
                    {
                        if (currentTypeSpec == null)
                        {
                            throw new IOException("Invalid chunk sequence: content read before typeSpec.");
                        }
                        var parent = currentTypeSpec;
                        var type   = Read(reader, () => new Type(parent, reader));
                        currentTypeSpec.Add(type);
                    }
                    else
                    {
                        throw new IOException("Unexpected chunk type (" + chunkType + ").");
                    }
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Default ctor
            /// </summary>
            internal Package(Table table, ResReader reader)
                : base(reader, ChunkTypes.RES_TABLE_PACKAGE_TYPE)
            {
                this.table = table;

                id = reader.ReadInt32();
                name = reader.ReadFixedLenghtUnicodeString(128);
                var typeStringsOffset = reader.ReadInt32();
                var lastPublicType = reader.ReadInt32();
                var keyStringsOffset = reader.ReadInt32();
                var lastPublicKey = reader.ReadInt32();

                // Record offset
                var dataOffset = reader.Position;

                // Data
                typeStrings = new StringPool(reader);
                keyStrings = new StringPool(reader);

                TypeSpec currentTypeSpec = null;
                while (reader.Position - dataOffset < DataSize)
                {
                    var chunkType = reader.PeekChunkType();
                    if (chunkType == ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE)
                    {
                        currentTypeSpec = Read(reader, () => new TypeSpec(this, reader));
                        typeSpecs.Add(currentTypeSpec);
                    }
                    else if (chunkType == ChunkTypes.RES_TABLE_TYPE_TYPE)
                    {
                        if (currentTypeSpec == null)
                        {
                            throw new IOException("Invalid chunk sequence: content read before typeSpec.");
                        }
                        var parent = currentTypeSpec;
                        var type = Read(reader, () => new Type(parent, reader));
                        currentTypeSpec.Add(type);
                    }
                    else
                    {
                        throw new IOException("Unexpected chunk type (" + chunkType + ").");
                    }
                }
            }