|
| 1 | +using System; |
| 2 | +using System.Threading; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using Npgsql.BackendMessages; |
| 5 | +using Npgsql.Internal.TypeHandling; |
| 6 | +using Npgsql.PostgresTypes; |
| 7 | + |
| 8 | +namespace Npgsql.Internal.TypeHandlers; |
| 9 | + |
| 10 | +sealed class UnsupportedHandler : NpgsqlTypeHandler |
| 11 | +{ |
| 12 | + readonly string _exceptionMessage; |
| 13 | + |
| 14 | + public UnsupportedHandler(PostgresType postgresType, string exceptionMessage) : base(postgresType) |
| 15 | + => _exceptionMessage = exceptionMessage; |
| 16 | + |
| 17 | + public override ValueTask<object> ReadAsObject(NpgsqlReadBuffer buf, int len, bool async, FieldDescription? fieldDescription = null) |
| 18 | + => throw new NotSupportedException(_exceptionMessage); |
| 19 | + |
| 20 | + public override int ValidateObjectAndGetLength(object value, ref NpgsqlLengthCache? lengthCache, NpgsqlParameter? parameter) |
| 21 | + => throw new NotSupportedException(_exceptionMessage); |
| 22 | + |
| 23 | + public override Task WriteObjectWithLength(object? value, NpgsqlWriteBuffer buf, NpgsqlLengthCache? lengthCache, NpgsqlParameter? parameter, bool async, |
| 24 | + CancellationToken cancellationToken = default) |
| 25 | + => throw new NotSupportedException(_exceptionMessage); |
| 26 | + |
| 27 | + protected internal override ValueTask<TAny> ReadCustom<TAny>(NpgsqlReadBuffer buf, int len, bool async, FieldDescription? fieldDescription) |
| 28 | + => throw new NotSupportedException(_exceptionMessage); |
| 29 | + |
| 30 | + protected override Task WriteWithLengthCustom<TAny>(TAny value, NpgsqlWriteBuffer buf, NpgsqlLengthCache? lengthCache, NpgsqlParameter? parameter, bool async, |
| 31 | + CancellationToken cancellationToken) |
| 32 | + => throw new NotSupportedException(_exceptionMessage); |
| 33 | + |
| 34 | + protected internal override int ValidateAndGetLengthCustom<TAny>(TAny value, ref NpgsqlLengthCache? lengthCache, NpgsqlParameter? parameter) |
| 35 | + => throw new NotSupportedException(_exceptionMessage); |
| 36 | + |
| 37 | + public override Type GetFieldType(FieldDescription? fieldDescription = null) |
| 38 | + => throw new NotSupportedException(_exceptionMessage); |
| 39 | + |
| 40 | + public override NpgsqlTypeHandler CreateArrayHandler(PostgresArrayType pgArrayType, ArrayNullabilityMode arrayNullabilityMode) |
| 41 | + => throw new NotSupportedException(_exceptionMessage); |
| 42 | + |
| 43 | + public override NpgsqlTypeHandler CreateRangeHandler(PostgresType pgRangeType) |
| 44 | + => throw new NotSupportedException(_exceptionMessage); |
| 45 | + |
| 46 | + public override NpgsqlTypeHandler CreateMultirangeHandler(PostgresMultirangeType pgMultirangeType) |
| 47 | + => throw new NotSupportedException(_exceptionMessage); |
| 48 | +} |
0 commit comments