/// <summary> /// Writes a message, without a tag, to the stream. /// The data is length-prefixed. /// </summary> /// <param name="value">The value to write</param> public void WriteMessage(IMessage value) { // TODO(jtattermusch): if the message doesn't implement IBufferMessage (and thus does not provide the InternalWriteTo method), // what we're doing here works fine, but could be more efficient. // For now, this inefficiency is fine, considering this is only a backward-compatibility scenario (and regenerating the code fixes it). var span = new Span <byte>(buffer); WriteContext.Initialize(ref span, ref state, out WriteContext ctx); try { WritingPrimitivesMessages.WriteMessage(ref ctx, value); } finally { ctx.CopyStateTo(this); } }
/// <summary> /// Writes a message, without a tag. /// The data is length-prefixed. /// </summary> /// <param name="value">The value to write</param> public void WriteMessage(IMessage value) { WritingPrimitivesMessages.WriteMessage(ref this, value); }