Exemplo n.º 1
0
 internal static void Initialize(IBufferWriter <byte> output, out WriteContext ctx)
 {
     ctx.buffer = default;
     ctx.state  = default;
     WriteBufferHelper.Initialize(output, out ctx.state.writeBufferHelper, out ctx.buffer);
     ctx.state.limit    = ctx.buffer.Length;
     ctx.state.position = 0;
 }
Exemplo n.º 2
0
 private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen)
 {
     this.output         = ProtoPreconditions.CheckNotNull(output, nameof(output));
     this.buffer         = buffer;
     this.state.position = 0;
     this.state.limit    = buffer.Length;
     WriteBufferHelper.Initialize(this, out this.state.writeBufferHelper);
     this.leaveOpen = leaveOpen;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new CodedOutputStream that writes directly to the given
 /// byte array slice. If more bytes are written than fit in the array,
 /// OutOfSpaceException will be thrown.
 /// </summary>
 private CodedOutputStream(byte[] buffer, int offset, int length)
 {
     this.output         = null;
     this.buffer         = ProtoPreconditions.CheckNotNull(buffer, nameof(buffer));
     this.state.position = offset;
     this.state.limit    = offset + length;
     WriteBufferHelper.Initialize(this, out this.state.writeBufferHelper);
     leaveOpen = true; // Simple way of avoiding trying to dispose of a null reference
 }