/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v8.0.3
src/Npgsql/Shims/DbDataSource.cs
70 строк
2 KB
Shay Rojansky
Fixes to DbDataSource (#4754)
12 ноя 2022, 12:41
Не верифицирован
12 ноя 2022, 12:41
55ad611
Код
Авторство
О чём код?
#if !NET7_0_OR_GREATER using System.Threading; using System.Threading.Tasks; #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (compatibility shim for old TFMs) // ReSharper disable once CheckNamespace namespace System.Data.Common; public abstract class DbDataSource : IDisposable, IAsyncDisposable { public abstract string ConnectionString { get; } protected abstract DbConnection CreateDbConnection(); // No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this. protected virtual DbConnection OpenDbConnection() => throw new NotSupportedException(); // No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this. protected virtual ValueTask<DbConnection> OpenDbConnectionAsync(CancellationToken cancellationToken = default) => throw new NotSupportedException(); // No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this. protected virtual DbCommand CreateDbCommand(string? commandText = null) => throw new NotSupportedException(); // No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this. protected virtual DbBatch CreateDbBatch() => throw new NotSupportedException(); public DbConnection CreateConnection() => CreateDbConnection(); public DbConnection OpenConnection() => OpenDbConnection(); public ValueTask<DbConnection> OpenConnectionAsync(CancellationToken cancellationToken = default) => OpenDbConnectionAsync(cancellationToken); public DbCommand CreateCommand(string? commandText = null) => CreateDbCommand(commandText); public DbBatch CreateBatch() => CreateDbBatch(); public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } public async ValueTask DisposeAsync() { await DisposeAsyncCore().ConfigureAwait(false); Dispose(disposing: false); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { } protected virtual ValueTask DisposeAsyncCore() => default; } #endif