public override void Write(PhysicalAddress value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter) => buf.WriteBytes(value.GetAddressBytes(), 0, 6);
// TODO: Can write directly from TimeSpan /// <inheritdoc /> public override void Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => Write(value, buf, parameter);
void INpgsqlSimpleTypeHandler <TimeSpan> .Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => _bclHandler.Write(value, buf, parameter);
public void SetUp() { Underlying = new MemoryStream(); WriteBuffer = new NpgsqlWriteBuffer(null, Underlying, NpgsqlReadBuffer.DefaultSize, PGUtil.UTF8Encoding); }
async Task INpgsqlTypeHandler <uint256> .Write(uint256 value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async) => await Write(value.ToBytes(), buf, lengthCache, parameter, async);
/// <inheritdoc /> public void Write(long value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteByte((byte)value);
void INpgsqlSimpleTypeHandler <DateTime> .Write(DateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => ((INpgsqlSimpleTypeHandler <DateTime>)_bclHandler).Write(value, buf, parameter);
/// <inheritdoc /> public override void Write(short value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16(value);
/// <inheritdoc /> public void Write(sbyte value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16(value);
void INpgsqlSimpleTypeHandler <NpgsqlDate> .Write(NpgsqlDate value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => _bclHandler.Write(value, buf, parameter);
/// <inheritdoc /> public override void Write(bool value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteByte(value ? (byte)1 : (byte)0);
public Task Write(NpgsqlTsQueryEmpty value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async) => Write((NpgsqlTsQuery)value, buf, lengthCache, parameter, async);
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(); }
/// <inheritdoc /> public void Write(decimal value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt64((long)value);
/// <inheritdoc /> public override void Write(TimeSpan value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt64(value.Ticks / 10);
/// <inheritdoc /> public void Write(float value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteInt16((short)value);
/// <inheritdoc /> public override void Write(char value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) => buf.WriteByte((byte)value);
/// <inheritdoc /> public override void Write(NpgsqlCircle value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter) { buf.WriteDouble(value.X); buf.WriteDouble(value.Y); buf.WriteDouble(value.Radius); }
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();
public override void Write(NpgsqlPoint value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter) { buf.WriteDouble(value.X); buf.WriteDouble(value.Y); }
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);
/// <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);
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);
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); }