Npgsql.WriteBuffer.DirectWrite C# (CSharp) Method

DirectWrite() private method

private DirectWrite ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
return void
        internal void DirectWrite(byte[] buffer, int offset, int count)
        {
            Contract.Requires(WritePosition == 0);

            try
            {
                Underlying.Write(buffer, offset, count);
            }
            catch (Exception e)
            {
                Connector.Break();
                throw new NpgsqlException("Exception while writing to stream", e);
            }
        }

Usage Example

示例#1
0
        internal async Task WritePassword(byte[] payload, int offset, int count, bool async)
        {
            if (WriteBuffer.WriteSpaceLeft < sizeof(byte) + sizeof(int))
            {
                await WriteBuffer.Flush(async);
            }
            WriteBuffer.WriteByte(FrontendMessageCode.Password);
            WriteBuffer.WriteInt32(sizeof(int) + count);

            if (count <= WriteBuffer.WriteSpaceLeft)
            {
                // The entire array fits in our WriteBuffer, copy it into the WriteBuffer as usual.
                WriteBuffer.WriteBytes(payload, offset, count);
                return;
            }

            await WriteBuffer.Flush(async);

            await WriteBuffer.DirectWrite(payload, offset, count, async);
        }
All Usage Examples Of Npgsql.WriteBuffer::DirectWrite