public static void Serialize (Stream stream, ReplyCustomHash instance) { if (instance.ChunkHash != null) { ProtocolParser.WriteKey (stream, new ProtocolBuffers.Key (1, Wire.LengthDelimited)); ProtocolParser.WriteBytes (stream, instance.ChunkHash); } }
public static byte[] SerializeToBytes (ReplyCustomHash instance) { using (MemoryStream ms = new MemoryStream()) { Serialize (ms, instance); return ms.ToArray (); } }
void ProcessGetCustomHash() { RequestCustomHash request = RequestCustomHash.Deserialize (ProtocolParser.ReadBytes (input)); ReplyCustomHash reply = new ReplyCustomHash (); ChunkHash ch = localRepo.GetCustomHash (CustomID.FromBytes (request.CustomID)); if (ch == null) reply.ChunkHash = null; else reply.ChunkHash = ch.bytes; //Console.Error.WriteLine("PipeServer: Sending: " + reply); byte[] rbytes = ReplyCustomHash.SerializeToBytes (reply); //Console.Error.WriteLine("PipeServer: Sending: " + rbytes.Length + ", " + BitConverter.ToString(rbytes)); ProtocolParser.WriteBytes (output, rbytes); }
public static ReplyCustomHash Deserialize (Stream stream) { ReplyCustomHash instance = new ReplyCustomHash (); Deserialize (stream, instance); return instance; }