Npgsql.WriteBuffer.WriteByte C# (CSharp) Method

WriteByte() public method

public WriteByte ( byte b ) : void
b byte
return void
        public void WriteByte(byte b)
        {
            Contract.Requires(WriteSpaceLeft >= sizeof(byte));
            _buf[_writePosition++] = b;
        }

Usage Example

示例#1
0
        internal Task WriteExecute(int maxRows, bool async)
        {
            // Note: non-empty portal currently not supported

            const int len = sizeof(byte) +       // Message code
                            sizeof(int) +        // Length
                            sizeof(byte) +       // Null-terminated portal name (always empty for now)
                            sizeof(int);         // Max number of rows

            if (WriteBuffer.WriteSpaceLeft < len)
            {
                return(FlushAndWrite(maxRows, async));
            }

            Write(maxRows);
            return(Task.CompletedTask);

            async Task FlushAndWrite(int maxRows, bool async)
            {
                await Flush(async);

                Debug.Assert(10 <= WriteBuffer.WriteSpaceLeft, $"Message of type {GetType().Name} has length 10 which is bigger than the buffer ({WriteBuffer.WriteSpaceLeft})");
                Write(maxRows);
            }

            void Write(int maxRows)
            {
                WriteBuffer.WriteByte(FrontendMessageCode.Execute);
                WriteBuffer.WriteInt32(len - 1);
                WriteBuffer.WriteByte(0);   // Portal is always empty for now
                WriteBuffer.WriteInt32(maxRows);
            }
        }
All Usage Examples Of Npgsql.WriteBuffer::WriteByte