/// <summary> /// Read ctor /// </summary> internal Type(TypeSpec parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_TYPE) { this.parent = parent; var id = reader.ReadByte(); reader.Skip(3); // reserved if (id != parent.Id) { throw new IOException("Type id (" + id + ") " + "doesn't match parent id (" + parent.Id + ")."); } var entryCount = reader.ReadInt32(); if (entryCount != parent.EntryCount) { throw new IOException(string.Format("Type entry count ({0}) doesn't match parent entry count ({1})", entryCount, parent.EntryCount)); } var entriesStart = reader.ReadInt32(); configuration = new Configuration(reader); // Data var offsets = reader.ReadIntArray(entryCount); var dataSize = (Size - entriesStart); if ((dataSize % 4) != 0) { throw new IOException("Type data size (" + dataSize + ") is not multiple of 4."); } for (var i = 0; i < entryCount; i++ ) { if (offsets[i] != NO_ENTRY) { var actualOffset = reader.Position; var instance = EntryInstance.Read(this, reader); parent.GetEntry(i).Add(instance); } } }
/// <summary> /// Reading ctor /// </summary> internal ResourceMap(ResReader reader) : base(reader, ChunkTypes.RES_XML_RESOURCE_MAP_TYPE) { if (Size < 8 || (Size % 4) != 0) { throw new IOException("Invalid resource ids size (" + Size + ")."); } resourceIds.AddRange(reader.ReadIntArray(Size / 4 - 2)); }
/// <summary> /// Reading ctor /// </summary> internal ResourceMap(ResReader reader) : base(reader, ChunkTypes.RES_XML_RESOURCE_MAP_TYPE) { if (Size < 8 || (Size % 4) != 0) { throw new IOException("Invalid resource ids size (" + Size + ")."); } resourceIds.AddRange(reader.ReadIntArray(Size / 4 - 2)); }
/// <summary> /// Default ctor /// </summary> internal StringPool(ResReader reader) : base(reader, ChunkTypes.RES_STRING_POOL_TYPE) { var stringCount = reader.ReadInt32(); var styleOffsetCount = reader.ReadInt32(); var flags = (StringPoolFlags)reader.ReadInt32(); IsUtf8 = ((flags & StringPoolFlags.UTF8_FLAG) != 0); var stringsStart = reader.ReadInt32(); var stylesStart = reader.ReadInt32(); var stringOffsets = reader.ReadIntArray(stringCount); if (styleOffsetCount != 0) { styleOffsets = reader.ReadIntArray(styleOffsetCount); } byte[] stringData; { var size = ((stylesStart == 0) ? Size : stylesStart) - stringsStart; if ((size % 4) != 0) { throw new IOException(string.Format("String data size is not multiple of 4 ({0}).", size)); } stringData = reader.ReadByteArray(size); } if (stylesStart != 0) { var size = (Size - stylesStart); if ((size % 4) != 0) { throw new IOException(string.Format("Style data size is not multiple of 4 ({0}).", size)); } styles = reader.ReadIntArray(size / 4); } var count = (stringOffsets != null) ? stringOffsets.Length : 0; for (var i = 0; i != count; ++i) { list.Add(new Entry(GetRaw(i, stringOffsets, stringData, IsUtf8, reader), -1)); } }
/// <summary> /// Reader ctor /// </summary> internal TypeSpec(Package parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { this.parent = parent; id = reader.ReadByte(); reader.Skip(3); // reserved var entryCount = reader.ReadInt32(); var flags = reader.ReadIntArray(entryCount).ToList(); entries.AddRange(flags.Select(x => new Entry(this, x))); }
/// <summary> /// Reader ctor /// </summary> internal TypeSpec(Package parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { this.parent = parent; id = reader.ReadByte(); reader.Skip(3); // reserved var entryCount = reader.ReadInt32(); var flags = reader.ReadIntArray(entryCount).ToList(); entries.AddRange(flags.Select(x => new Entry(this, x))); }
/// <summary> /// Read ctor /// </summary> internal Type(TypeSpec parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_TYPE) { this.parent = parent; var id = reader.ReadByte(); reader.Skip(3); // reserved if (id != parent.Id) { throw new IOException("Type id (" + id + ") " + "doesn't match parent id (" + parent.Id + ")."); } var entryCount = reader.ReadInt32(); if (entryCount != parent.EntryCount) { throw new IOException(string.Format("Type entry count ({0}) doesn't match parent entry count ({1})", entryCount, parent.EntryCount)); } var entriesStart = reader.ReadInt32(); configuration = new Configuration(reader); // Data var offsets = reader.ReadIntArray(entryCount); var dataSize = (Size - entriesStart); if ((dataSize % 4) != 0) { throw new IOException("Type data size (" + dataSize + ") is not multiple of 4."); } for (var i = 0; i < entryCount; i++) { if (offsets[i] != NO_ENTRY) { var actualOffset = reader.Position; var instance = EntryInstance.Read(this, reader); parent.GetEntry(i).Add(instance); } } }