/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v6.0.11
src/Npgsql.NodaTime/Internal/LegacyTimestampHandler.cs
64 строки
3 KB
Shay Rojansky
Apply file-scoped namespaces for 6.0 (#4298)
28 янв 2022, 15:13
Не верифицирован
28 янв 2022, 15:13
2e0ad2d
Код
Авторство
О чём код?
using System; using System.Diagnostics; using NodaTime; using Npgsql.BackendMessages; using Npgsql.Internal; using Npgsql.Internal.TypeHandling; using Npgsql.PostgresTypes; using BclTimestampHandler = Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimestampHandler; namespace Npgsql.NodaTime.Internal; sealed partial class LegacyTimestampHandler : NpgsqlSimpleTypeHandler<Instant>, INpgsqlSimpleTypeHandler<LocalDateTime>, INpgsqlSimpleTypeHandler<DateTime>, INpgsqlSimpleTypeHandler<long> { readonly BclTimestampHandler _bclHandler; internal LegacyTimestampHandler(PostgresType postgresType) : base(postgresType) => _bclHandler = new BclTimestampHandler(postgresType); #region Read public override Instant Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription = null) => TimestampTzHandler.ReadInstant(buf); LocalDateTime INpgsqlSimpleTypeHandler<LocalDateTime>.Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription) => TimestampHandler.ReadLocalDateTime(buf); DateTime INpgsqlSimpleTypeHandler<DateTime>.Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription) => _bclHandler.Read(buf, len, fieldDescription); long INpgsqlSimpleTypeHandler<long>.Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription) => ((INpgsqlSimpleTypeHandler<long>)_bclHandler).Read(buf, len, fieldDescription); #endregion Read #region Write public override int ValidateAndGetLength(Instant value, NpgsqlParameter? parameter) => 8; int INpgsqlSimpleTypeHandler<LocalDateTime>.ValidateAndGetLength(LocalDateTime value, NpgsqlParameter? parameter) => 8; public override void Write(Instant value, NpgsqlWriteBuffer buf, NpgsqlParameter? parameter) => TimestampTzHandler.WriteInstant(value, buf); void INpgsqlSimpleTypeHandler<LocalDateTime>.Write(LocalDateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter? parameter) => TimestampHandler.WriteLocalDateTime(value, buf); int INpgsqlSimpleTypeHandler<DateTime>.ValidateAndGetLength(DateTime value, NpgsqlParameter? parameter) => ((INpgsqlSimpleTypeHandler<DateTime>)_bclHandler).ValidateAndGetLength(value, parameter); public int ValidateAndGetLength(long value, NpgsqlParameter? parameter) => ((INpgsqlSimpleTypeHandler<long>)_bclHandler).ValidateAndGetLength(value, parameter); void INpgsqlSimpleTypeHandler<DateTime>.Write(DateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter? parameter) => ((INpgsqlSimpleTypeHandler<DateTime>)_bclHandler).Write(value, buf, parameter); void INpgsqlSimpleTypeHandler<long>.Write(long value, NpgsqlWriteBuffer buf, NpgsqlParameter? parameter) => ((INpgsqlSimpleTypeHandler<long>)_bclHandler).Write(value, buf, parameter); #endregion Write }