Пример #1
0
 public override void Write(PhysicalAddress value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
 => buf.WriteBytes(value.GetAddressBytes(), 0, 6);
Пример #2
0
 // TODO: Can write directly from TimeSpan
 /// <inheritdoc />
 public override void Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => Write(value, buf, parameter);
Пример #3
0
 void INpgsqlSimpleTypeHandler <TimeSpan> .Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => _bclHandler.Write(value, buf, parameter);
Пример #4
0
 public void SetUp()
 {
     Underlying  = new MemoryStream();
     WriteBuffer = new NpgsqlWriteBuffer(null, Underlying, NpgsqlReadBuffer.DefaultSize, PGUtil.UTF8Encoding);
 }
Пример #5
0
 async Task INpgsqlTypeHandler <uint256> .Write(uint256 value, NpgsqlWriteBuffer buf,
                                                NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
 => await Write(value.ToBytes(), buf, lengthCache, parameter, async);
Пример #6
0
 /// <inheritdoc />
 public void Write(long value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteByte((byte)value);
Пример #7
0
 void INpgsqlSimpleTypeHandler <DateTime> .Write(DateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => ((INpgsqlSimpleTypeHandler <DateTime>)_bclHandler).Write(value, buf, parameter);
Пример #8
0
 /// <inheritdoc />
 public override void Write(short value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16(value);
Пример #9
0
 /// <inheritdoc />
 public void Write(sbyte value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16(value);
Пример #10
0
 void INpgsqlSimpleTypeHandler <NpgsqlDate> .Write(NpgsqlDate value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => _bclHandler.Write(value, buf, parameter);
Пример #11
0
 /// <inheritdoc />
 public override void Write(bool value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => buf.WriteByte(value ? (byte)1 : (byte)0);
Пример #12
0
 public Task Write(NpgsqlTsQueryEmpty value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
 => Write((NpgsqlTsQuery)value, buf, lengthCache, parameter, async);
Пример #13
0
        public override async Task Write(NpgsqlTsQuery query, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
        {
            var numTokens = GetTokenCount(query);

            if (buf.WriteSpaceLeft < 4)
            {
                await buf.Flush(async);
            }
            buf.WriteInt32(numTokens);

            if (numTokens == 0)
            {
                return;
            }

            _stack.Push(query);

            while (_stack.Count > 0)
            {
                if (buf.WriteSpaceLeft < 2)
                {
                    await buf.Flush(async);
                }

                if (_stack.Peek().Kind == NpgsqlTsQuery.NodeKind.Lexeme && buf.WriteSpaceLeft < MaxSingleTokenBytes)
                {
                    await buf.Flush(async);
                }

                var node = _stack.Pop();
                buf.WriteByte(node.Kind == NpgsqlTsQuery.NodeKind.Lexeme ? (byte)1 : (byte)2);
                if (node.Kind != NpgsqlTsQuery.NodeKind.Lexeme)
                {
                    buf.WriteByte((byte)node.Kind);
                    if (node.Kind == NpgsqlTsQuery.NodeKind.Not)
                    {
                        _stack.Push(((NpgsqlTsQueryNot)node).Child);
                    }
                    else
                    {
                        if (node.Kind == NpgsqlTsQuery.NodeKind.Phrase)
                        {
                            buf.WriteInt16(((NpgsqlTsQueryFollowedBy)node).Distance);
                        }

                        _stack.Push(((NpgsqlTsQueryBinOp)node).Right);
                        _stack.Push(((NpgsqlTsQueryBinOp)node).Left);
                    }
                }
                else
                {
                    var lexemeNode = (NpgsqlTsQueryLexeme)node;
                    buf.WriteByte((byte)lexemeNode.Weights);
                    buf.WriteByte(lexemeNode.IsPrefixSearch ? (byte)1 : (byte)0);
                    buf.WriteString(lexemeNode.Text);
                    buf.WriteByte(0);
                }
            }

            _stack.Clear();
        }
Пример #14
0
 /// <inheritdoc />
 public void Write(decimal value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt64((long)value);
Пример #15
0
 /// <inheritdoc />
 public override void Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => buf.WriteInt64(value.Ticks / 10);
Пример #16
0
 /// <inheritdoc />
 public void Write(float value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16((short)value);
Пример #17
0
 /// <inheritdoc />
 public override void Write(char value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteByte((byte)value);
Пример #18
0
 /// <inheritdoc />
 public override void Write(NpgsqlCircle value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 {
     buf.WriteDouble(value.X);
     buf.WriteDouble(value.Y);
     buf.WriteDouble(value.Radius);
 }
Пример #19
0
 void INpgsqlSimpleTypeHandler <LocalDateTime> .Write(LocalDateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => WriteInteger(value.InUtc().ToInstant(), buf);
 public override void Write(DBNull value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => throw new NotSupportedException();
Пример #21
0
 public override void Write(NpgsqlPoint value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
 {
     buf.WriteDouble(value.X);
     buf.WriteDouble(value.Y);
 }
Пример #22
0
 public void Write(double value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
 => Write((decimal)value, buf, parameter);
 /// <summary>
 /// Writes a value to the provided buffer, with the assumption that there is enough space in the buffer
 /// (no I/O will occur). The Npgsql core will have taken care of that.
 /// </summary>
 /// <param name="value">The value to write.</param>
 /// <param name="buf">The buffer to which to write.</param>
 /// <param name="parameter">
 /// The <see cref="NpgsqlParameter"/> instance where this value resides. Can be used to access additional
 /// information relevant to the write process (e.g. <see cref="NpgsqlParameter.Size"/>).
 /// </param>
 public abstract void Write(TPsv value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter);
 /// <inheritdoc />
 public void Write(long value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => buf.WriteInt64(value);
Пример #25
0
 /// <inheritdoc />
 public override void Write(NpgsqlTimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 {
     buf.WriteInt64(value.Ticks / 10); // TODO: round?
     buf.WriteInt32(value.Days);
     buf.WriteInt32(value.Months);
 }
 /// <summary>
 /// Called to write the value of a generic <see cref="NpgsqlParameter{T}"/>.
 /// </summary>
 internal abstract Task WriteWithLengthInternal <TAny>([CanBeNull] TAny value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async);
Пример #27
0
 public override void Write(LocalTime value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => buf.WriteInt64(value.TickOfDay / 10);
 /// <summary>
 /// Writes a value to the provided buffer, using either sync or async I/O.
 /// </summary>
 /// <param name="value">The value to write.</param>
 /// <param name="buf">The buffer to which to write.</param>
 /// <param name="lengthCache"></param>
 /// <param name="parameter">
 /// The <see cref="NpgsqlParameter"/> instance where this value resides. Can be used to access additional
 /// information relevant to the write process (e.g. <see cref="NpgsqlParameter.Size"/>).
 /// </param>
 /// <param name="async">If I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously.</param>
 protected internal abstract Task WriteObjectWithLength([CanBeNull] object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async);
Пример #29
0
 public void Write(TimeOnly value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => _bclHandler.Write(value, buf, parameter);
 internal override void WriteFully(NpgsqlWriteBuffer buf)
 {
     buf.WriteInt32(Length);
     buf.WriteInt32(80877103);
 }