示例#1
0
        private void WriteExtraDataSection(BinaryWriter writer)
        {
            foreach (var blockWriter in Item.ExtraDataBlocks.Select(block => ExtraDataBlockHandlerFactory.GetInstance(block, Item)))
            {
                blockWriter.WriteTo(writer);
            }

            writer.Write(0);
        }
示例#2
0
        private void ReadExtraDataSection(BinaryReader reader)
        {
            Item.ExtraDataBlocks = new List <ExtraDataBlock>();
            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                int blocksize = reader.ReadInt32();
                if (blocksize < 0x4) // Terminal Block
                {
                    break;
                }

                var signature = (ExtraDataBlockSignature)(reader.ReadInt32());
                var block     = ExtraDataBlockFactory.GetInstance(signature);
                Item.ExtraDataBlocks.Add(block);

                var blockReader = ExtraDataBlockHandlerFactory.GetInstance(block, Item);
                reader.BaseStream.Seek(-Marshal.SizeOf(blocksize) - Marshal.SizeOf(typeof(int)), SeekOrigin.Current);
                blockReader.ReadFrom(reader);
            }
        }