Exemplo n.º 1
0
        protected override async Task Write(object value, WriteBuffer buf, LengthCache lengthCache, NpgsqlParameter parameter,
                                            bool async, CancellationToken cancellationToken)
        {
            var asDict = (IDictionary <string, string>)value;

            if (buf.WriteSpaceLeft < 4)
            {
                await buf.Flush(async, cancellationToken);
            }
            buf.WriteInt32(asDict.Count);
            if (asDict.Count == 0)
            {
                return;
            }

            foreach (var kv in asDict)
            {
                await _textHandler.WriteWithLength(kv.Key, buf, lengthCache, parameter, async, cancellationToken);

                await _textHandler.WriteWithLength(kv.Value, buf, lengthCache, parameter, async, cancellationToken);
            }
        }