public static AtomicHeader Deserialize(Stream stream) { AtomicHeader header = new AtomicHeader(); stream.Seek(0, SeekOrigin.Begin); byte[] buffer = new byte[SIZE]; if (stream.Read(buffer, 0, SIZE) != SIZE) { throw new Exception(String.Format("Invalid {0} header.", TITLE)); } using (MemoryStream ms = new MemoryStream(buffer)) { BinaryReader reader = new BinaryReader(ms); string title = reader.ReadString(); if (title != TITLE) { throw new Exception(String.Format("Invalid {0} header.", TITLE)); } header.Version = reader.ReadInt32(); header.UseCompression = reader.ReadBoolean(); //last flush location header.SystemData = Ptr.Deserialize(reader); //tag int tagLength = reader.ReadInt32(); header.Tag = tagLength >= 0 ? reader.ReadBytes(tagLength) : null; } return(header); }
public static Pointer Deserialize(BinaryReader reader) { long version = reader.ReadInt64(); Ptr ptr = Ptr.Deserialize(reader); return(new Pointer(version, ptr)); }
public void Deserealize(BinaryReader reader) { Strategy = (AllocationStrategy)reader.ReadByte(); activeChunkIndex = reader.ReadInt32(); int count = reader.ReadInt32(); free.Clear(); FreeBytes = 0; for (int i = 0; i < count; i++) { var ptr = Ptr.Deserialize(reader); free.Add(ptr); FreeBytes += ptr.Size; } }