Exemplo n.º 1
0
        private protected async Task Write <TAny>(NpgsqlRange <TAny> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache?lengthCache, NpgsqlParameter?parameter, bool async, CancellationToken cancellationToken = default)
        {
            if (buf.WriteSpaceLeft < 1)
            {
                await buf.Flush(async, cancellationToken);
            }

            buf.WriteByte((byte)value.Flags);

            if (value.IsEmpty)
            {
                return;
            }

            if (!value.LowerBoundInfinite)
            {
                await _elementHandler.WriteWithLengthInternal(value.LowerBound, buf, lengthCache, null, async, cancellationToken);
            }

            if (!value.UpperBoundInfinite)
            {
                await _elementHandler.WriteWithLengthInternal(value.UpperBound, buf, lengthCache, null, async, cancellationToken);
            }
        }
Exemplo n.º 2
0
        public override async Task Write(TComposite composite, NpgsqlWriteBuffer buffer, NpgsqlLengthCache?lengthCache, bool async, CancellationToken cancellationToken = default)
        {
            if (_get == null)
            {
                ThrowHelper.ThrowInvalidOperationException_NoPropertyGetter(typeof(TComposite), MemberInfo);
            }

            if (buffer.WriteSpaceLeft < sizeof(int))
            {
                await buffer.Flush(async, cancellationToken);
            }

            buffer.WriteUInt32(PostgresType.OID);
            await(NullableHandler <TMember> .Exists
                ? NullableHandler <TMember> .WriteAsync(_handler, _get(ref composite), buffer, lengthCache, null, async, cancellationToken)
                : _handler.WriteWithLengthInternal(_get(ref composite), buffer, lengthCache, null, async, cancellationToken));
        }