Esempio n. 1
0
        internal static PregeneratedMessage Generate(NpgsqlWriteBuffer buf, QueryMessage queryMessage, string query, int responseMessageCount = 2)
        {
            Debug.Assert(query != null && query.All(c => c < 128));
            queryMessage.Populate(query);
            var description = queryMessage.ToString();

            queryMessage.Write(buf, false).Wait();
            var bytes = buf.GetContents();

            buf.Clear();
            return(new PregeneratedMessage(bytes, description, responseMessageCount));
        }
Esempio n. 2
0
    internal static byte[] Generate(NpgsqlWriteBuffer buf, string query)
    {
        Debug.Assert(query.All(c => c < 128));

        var queryByteLen = Encoding.ASCII.GetByteCount(query);

        buf.WriteByte(FrontendMessageCode.Query);
        buf.WriteInt32(4 +            // Message length (including self excluding code)
                       queryByteLen + // Query byte length
                       1);            // Null terminator

        buf.WriteString(query, queryByteLen, false).Wait();
        buf.WriteByte(0);

        var bytes = buf.GetContents();

        buf.Clear();
        return(bytes);
    }