public static void WriteObject <T> (this PipeStream pipeStream, T obj) { var stream = ObjectStreamer.SerializeToStream(obj); byte[] msgBuff = stream.ToArray(); pipeStream.Write(msgBuff, 0, msgBuff.Length); }
public static T ReadObject <T>(this PipeStream pipeStream) where T : class { int BUFFSIZE = 1024; int byteCount = 0; var msgBuff = new byte[BUFFSIZE]; var fullMessage = new List <byte>(); do { byteCount = pipeStream.Read(msgBuff, 0, BUFFSIZE); fullMessage.AddRange(msgBuff); } while (!(pipeStream.IsMessageComplete)); MemoryStream stream = new MemoryStream(fullMessage.ToArray()); return(ObjectStreamer.DeserializeFromStream(stream) as T); }