public object Deserialize(BinaryReader reader) { int id = (int)reader.ReadByte(); ObjectStreamer objectStreamer = this.streamerByTypeId[id]; return(objectStreamer.Read(reader)); }
public void Serialize(BinaryWriter writer, object obj) { Type type = obj.GetType(); ObjectStreamer objectStreamer = this.streamerByType[type]; writer.Write(objectStreamer.typeId); objectStreamer.Write(writer, obj); }
internal byte[] WriteObjectData() { MemoryStream memoryStream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(memoryStream); ObjectStreamer objectStreamer = this.file.streamerManager.streamerByType[this.obj.GetType()]; objectStreamer.Write(writer, this.obj); byte[] array = memoryStream.ToArray(); if (this.compressionLevel == 0) { return(array); } QuickLZ quickLZ = new QuickLZ(); return(quickLZ.Compress(array)); }
public virtual object GetObject() { if (this.obj != null) { return(this.obj); } if (this.objLength == -1) { return(null); } MemoryStream input = new MemoryStream(this.ReadObjectData()); BinaryReader reader = new BinaryReader(input); ObjectStreamer objectStreamer = this.file.streamerManager.streamerByTypeId[(int)this.typeId]; this.obj = objectStreamer.Read(reader); if (this.typeId == 101) { ((DataSeries)this.obj).Init(this.file, this); } return(this.obj); }
public void Add(ObjectStreamer streamer) { throw new NotImplementedException(); }
public void Add(ObjectStreamer streamer) { streamer.streamerManager = this; this.streamerByTypeId[(int)streamer.typeId] = streamer; this.streamerByType[streamer.type] = streamer; }