77
88namespace Npgsql ;
99
10- sealed class MultiHostDataSourceWrapper : NpgsqlDataSource
10+ sealed class MultiHostDataSourceWrapper ( NpgsqlMultiHostDataSource wrappedSource , TargetSessionAttributes targetSessionAttributes )
11+ : NpgsqlDataSource ( CloneSettingsForTargetSessionAttributes ( wrappedSource . Settings , targetSessionAttributes ) , wrappedSource . Configuration )
1112{
1213 internal override bool OwnsConnectors => false ;
1314
14- readonly NpgsqlMultiHostDataSource _wrappedSource ;
15-
16- public MultiHostDataSourceWrapper ( NpgsqlMultiHostDataSource source , TargetSessionAttributes targetSessionAttributes )
17- : base ( CloneSettingsForTargetSessionAttributes ( source . Settings , targetSessionAttributes ) , source . Configuration )
18- => _wrappedSource = source ;
15+ public override void Clear ( ) => wrappedSource . Clear ( ) ;
1916
2017 static NpgsqlConnectionStringBuilder CloneSettingsForTargetSessionAttributes (
2118 NpgsqlConnectionStringBuilder settings ,
@@ -26,23 +23,22 @@ static NpgsqlConnectionStringBuilder CloneSettingsForTargetSessionAttributes(
2623 return clonedSettings ;
2724 }
2825
29- internal override ( int Total , int Idle , int Busy ) Statistics => _wrappedSource . Statistics ;
26+ internal override ( int Total , int Idle , int Busy ) Statistics => wrappedSource . Statistics ;
3027
31- internal override void Clear ( ) => _wrappedSource . Clear ( ) ;
3228 internal override ValueTask < NpgsqlConnector > Get ( NpgsqlConnection conn , NpgsqlTimeout timeout , bool async , CancellationToken cancellationToken )
33- => _wrappedSource . Get ( conn , timeout , async , cancellationToken ) ;
29+ => wrappedSource . Get ( conn , timeout , async , cancellationToken ) ;
3430 internal override bool TryGetIdleConnector ( [ NotNullWhen ( true ) ] out NpgsqlConnector ? connector )
3531 => throw new NpgsqlException ( "Npgsql bug: trying to get an idle connector from " + nameof ( MultiHostDataSourceWrapper ) ) ;
3632 internal override ValueTask < NpgsqlConnector ? > OpenNewConnector ( NpgsqlConnection conn , NpgsqlTimeout timeout , bool async , CancellationToken cancellationToken )
3733 => throw new NpgsqlException ( "Npgsql bug: trying to open a new connector from " + nameof ( MultiHostDataSourceWrapper ) ) ;
3834 internal override void Return ( NpgsqlConnector connector )
39- => _wrappedSource . Return ( connector ) ;
35+ => wrappedSource . Return ( connector ) ;
4036
4137 internal override void AddPendingEnlistedConnector ( NpgsqlConnector connector , Transaction transaction )
42- => _wrappedSource . AddPendingEnlistedConnector ( connector , transaction ) ;
38+ => wrappedSource . AddPendingEnlistedConnector ( connector , transaction ) ;
4339 internal override bool TryRemovePendingEnlistedConnector ( NpgsqlConnector connector , Transaction transaction )
44- => _wrappedSource . TryRemovePendingEnlistedConnector ( connector , transaction ) ;
40+ => wrappedSource . TryRemovePendingEnlistedConnector ( connector , transaction ) ;
4541 internal override bool TryRentEnlistedPending ( Transaction transaction , NpgsqlConnection connection ,
4642 [ NotNullWhen ( true ) ] out NpgsqlConnector ? connector )
47- => _wrappedSource . TryRentEnlistedPending ( transaction , connection , out connector ) ;
48- }
43+ => wrappedSource . TryRentEnlistedPending ( transaction , connection , out connector ) ;
44+ }
0 commit comments