/// <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 + ")."); } } }
/// <summary> /// Reading ctor /// </summary> public XmlTree(ResReader reader) : base(reader, ChunkTypes.RES_XML_TYPE) { strings = new StringPool(reader); resourceMap = new ResourceMap(reader); while (true) { var tag = reader.PeekChunkType(); Node node; switch (tag) { case ChunkTypes.RES_XML_START_NAMESPACE_TYPE: node = new StartNamespace(reader, this); break; case ChunkTypes.RES_XML_START_ELEMENT_TYPE: node = new StartElement(reader, this); break; case ChunkTypes.RES_XML_CDATA_TYPE: node = new CData(reader, this); break; case ChunkTypes.RES_XML_END_ELEMENT_TYPE: node = new EndElement(reader, this); break; case ChunkTypes.RES_XML_END_NAMESPACE_TYPE: node = new EndNamespace(reader, this); break; default: throw new IOException(string.Format("Unexpected tag: 0x{0:X}", (int)tag)); } nodes.Add(node); if (tag == ChunkTypes.RES_XML_END_NAMESPACE_TYPE) { break; } } }
/// <summary> /// Reading ctor /// </summary> public XmlTree(ResReader reader) : base(reader, ChunkTypes.RES_XML_TYPE) { strings = new StringPool(reader); resourceMap = new ResourceMap(reader); while (true) { var tag = reader.PeekChunkType(); Node node; switch (tag) { case ChunkTypes.RES_XML_START_NAMESPACE_TYPE: node = new StartNamespace(reader, this); break; case ChunkTypes.RES_XML_START_ELEMENT_TYPE: node = new StartElement(reader, this); break; case ChunkTypes.RES_XML_CDATA_TYPE: node = new CData(reader, this); break; case ChunkTypes.RES_XML_END_ELEMENT_TYPE: node = new EndElement(reader, this); break; case ChunkTypes.RES_XML_END_NAMESPACE_TYPE: node = new EndNamespace(reader, this); break; default: throw new IOException(string.Format("Unexpected tag: 0x{0:X}", (int)tag)); } nodes.Add(node); if (tag == ChunkTypes.RES_XML_END_NAMESPACE_TYPE) break; } }