long LengthOf(IBinaryMessage message) { using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { message.WriteTo(writer); return(stream.Length); } }
static string GetMessageAsBase64ForUseInTestProcess(IBinaryMessage msg) { using (var m = new MemoryStream()) using (var w = new BinaryWriter(m)) { msg.WriteTo(w); m.Seek(0, SeekOrigin.Begin); return(Convert.ToBase64String(m.GetBuffer(), 0, (int)m.Length)); } }