Example #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 _subtypeHandler.WriteWithLength(value.LowerBound, buf, lengthCache, null, async, cancellationToken);
            }

            if (!value.UpperBoundInfinite)
            {
                await _subtypeHandler.WriteWithLength(value.UpperBound, buf, lengthCache, null, async, cancellationToken);
            }
        }
        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.WriteWithLength(_get(ref composite), buffer, lengthCache, null, async, cancellationToken));
        }