@@ -9,48 +9,48 @@ namespace Open.Database.Extensions.Core;
99/// </summary>
1010/// <typeparam name="TConnection"></typeparam>
1111internal class DbConnectionProvider < TConnection > : IDbConnectionPool < TConnection >
12- where TConnection : class , IDbConnection
12+ where TConnection : class , IDbConnection
1313{
14- public DbConnectionProvider ( TConnection connection )
15- {
16- Connection = connection ?? throw new ArgumentNullException ( nameof ( connection ) ) ;
17- }
14+ public DbConnectionProvider ( TConnection connection )
15+ {
16+ Connection = connection ?? throw new ArgumentNullException ( nameof ( connection ) ) ;
17+ }
1818
19- private TConnection Connection { get ; }
19+ private TConnection Connection { get ; }
2020
21- private ConnectionState ? TakenConnectionState ;
21+ private ConnectionState ? TakenConnectionState ;
2222
23- /// <inheritdoc />
24- public TConnection Take ( )
25- {
26- if ( TakenConnectionState . HasValue )
27- throw new InvalidOperationException ( "Concurrent use of a single connection is not supported." ) ;
23+ /// <inheritdoc />
24+ public TConnection Take ( )
25+ {
26+ if ( TakenConnectionState . HasValue )
27+ throw new InvalidOperationException ( "Concurrent use of a single connection is not supported." ) ;
2828
29- TakenConnectionState = Connection . State ;
30- return Connection ;
31- }
29+ TakenConnectionState = Connection . State ;
30+ return Connection ;
31+ }
3232
33- IDbConnection IDbConnectionPool . Take ( ) => Take ( ) ;
33+ IDbConnection IDbConnectionPool . Take ( ) => Take ( ) ;
3434
35- /// <inheritdoc />
36- public void Give ( IDbConnection connection )
37- {
38- if ( connection is null )
35+ /// <inheritdoc />
36+ public void Give ( IDbConnection connection )
37+ {
38+ if ( connection is null )
3939 throw new ArgumentNullException ( nameof ( connection ) ) ;
40- if ( connection != Connection )
40+ if ( connection != Connection )
4141 throw new ArgumentException ( "Does not belong to this provider." , nameof ( connection ) ) ;
42- Contract . EndContractBlock ( ) ;
42+ Contract . EndContractBlock ( ) ;
4343
44- if ( TakenConnectionState == ConnectionState . Closed )
45- connection . Close ( ) ;
44+ if ( TakenConnectionState == ConnectionState . Closed )
45+ connection . Close ( ) ;
4646
47- TakenConnectionState = null ;
48- }
47+ TakenConnectionState = null ;
48+ }
4949}
5050
5151internal static class DbConnectionProvider
5252{
53- public static DbConnectionProvider < TConnection > Create < TConnection > ( TConnection connection )
54- where TConnection : class , IDbConnection
55- => new ( connection ) ;
53+ public static DbConnectionProvider < TConnection > Create < TConnection > ( TConnection connection )
54+ where TConnection : class , IDbConnection
55+ => new ( connection ) ;
5656}
0 commit comments