Npgsql.WriteBuffer.WriteBytes C# (CSharp) Method

WriteBytes() public method

public WriteBytes ( byte buf, int offset, int count ) : void
buf byte
offset int
count int
return void
        public void WriteBytes(byte[] buf, int offset, int count)
        {
            Contract.Requires(count <= WriteSpaceLeft);
            Buffer.BlockCopy(buf, offset, _buf, WritePosition, count);
            WritePosition += count;
        }

Usage Example

示例#1
0
        internal async Task WriteSASLInitialResponse(string mechanism, byte[] initialResponse, bool async)
        {
            var len = sizeof(byte) +                                                // Message code
                      sizeof(int) +                                                 // Length
                      PGUtil.UTF8Encoding.GetByteCount(mechanism) + sizeof(byte) +  // Mechanism plus null terminator
                      sizeof(int) +                                                 // Initial response length
                      (initialResponse?.Length ?? 0);                               // Initial response payload

            if (WriteBuffer.WriteSpaceLeft < len)
            {
                await WriteBuffer.Flush(async);
            }

            WriteBuffer.WriteByte(FrontendMessageCode.Password);
            WriteBuffer.WriteInt32(len - 1);

            WriteBuffer.WriteString(mechanism);
            WriteBuffer.WriteByte(0);   // null terminator
            if (initialResponse == null)
            {
                WriteBuffer.WriteInt32(-1);
            }
            else
            {
                WriteBuffer.WriteInt32(initialResponse.Length);
                WriteBuffer.WriteBytes(initialResponse);
            }
        }
All Usage Examples Of Npgsql.WriteBuffer::WriteBytes