Exemplo n.º 1
0
        public override ValueTask <T> Read(NpgsqlReadBuffer buffer, int length, bool async, FieldDescription?fieldDescription = null)
        {
            Initialize();

            return(_constructorHandler is null
                ? ReadUsingMemberHandlers()
                : _constructorHandler.Read(buffer, async));

            async ValueTask <T> ReadUsingMemberHandlers()
            {
                await buffer.Ensure(sizeof(int), async);

                var fieldCount = buffer.ReadInt32();

                if (fieldCount != _memberHandlers.Length)
                {
                    throw new InvalidOperationException($"pg_attributes contains {_memberHandlers.Length} fields for type {PgDisplayName}, but {fieldCount} fields were received.");
                }

                if (IsValueType <T> .Value)
                {
                    var composite = new ByReference <T> {
                        Value = _constructor()
                    };
                    foreach (var member in _memberHandlers)
                    {
                        await member.Read(composite, buffer, async);
                    }

                    return(composite.Value);
                }
                else
                {
                    var composite = _constructor();
                    foreach (var member in _memberHandlers)
                    {
                        await member.Read(composite, buffer, async);
                    }

                    return(composite);
                }
            }
        }
Exemplo n.º 2
0
 public override ValueTask Read(ByReference <TComposite> composite, NpgsqlReadBuffer buffer, bool async, CancellationToken cancellationToken = default)
 => throw new NotSupportedException();
Exemplo n.º 3
0
 void Set(ByReference <TComposite> composite, TMember value)
 {
     _set !(ref composite.Value, value);
 }
Exemplo n.º 4
0
 public abstract ValueTask Read(ByReference <TComposite> composite, NpgsqlReadBuffer buffer, bool async, CancellationToken cancellationToken = default);
 public override ValueTask Read(ByReference <TComposite> composite, NpgsqlReadBuffer buffer, bool async)
 => throw new NotSupportedException();
Exemplo n.º 6
0
 public abstract ValueTask Read(ByReference <TComposite> composite, NpgsqlReadBuffer buffer, bool async);