/// <summary> /// Performs the initialization of a <see cref="PooledDbConnection"/> as it is grabbed from the object pool. /// </summary> /// <param name="conn">The <see cref="PooledDbConnection"/> to initialize.</param> protected virtual void InitializePooledConnection(PooledDbConnection conn) { if (conn.Connection.State != ConnectionState.Open) { conn.Connection.Open(); } }
/// <summary> /// Creates a new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>. /// </summary> /// <param name="objectPool">The owner object pool.</param> /// <returns>A new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>.</returns> PooledDbConnection CreateNewObj(IObjectPool<PooledDbConnection> objectPool) { var ret = new PooledDbConnection(this); var conn = CreateConnection(ConnectionString); ret.SetConnection(conn); return ret; }
/// <summary> /// Creates a new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>. /// </summary> /// <param name="objectPool">The owner object pool.</param> /// <returns>A new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>.</returns> PooledDbConnection CreateNewObj(IObjectPool <PooledDbConnection> objectPool) { var ret = new PooledDbConnection(this); var conn = CreateConnection(ConnectionString); ret.SetConnection(conn); return(ret); }
/// <summary> /// Performs the deinitialization of a <see cref="PooledDbConnection"/> as it is released back into the object pool. /// </summary> /// <param name="conn">The <see cref="PooledDbConnection"/> to deinitialize.</param> protected virtual void DeinitializePooledConnection(PooledDbConnection conn) { conn.Connection.Close(); }
/// <summary> /// Frees the object so the pool can reuse it. After freeing an object, it should not be used /// in any way, and be treated like it has been disposed. /// </summary> /// <param name="poolObject">The object to be freed.</param> /// <param name="throwArgumentException">Whether or not an <see cref="ArgumentException"/> will be thrown for /// objects that do not belong to this pool.</param> /// <exception cref="ArgumentException"><paramref name="throwArgumentException"/> is tru and the /// <paramref name="poolObject"/> does not belong to this pool.</exception> /// <exception cref="ArgumentNullException"><paramref name="poolObject"/> is null.</exception> public void Free(PooledDbConnection poolObject, bool throwArgumentException) { _pool.Free(poolObject, throwArgumentException); }
/// <summary> /// Frees the object so the pool can reuse it. After freeing an object, it should not be used /// in any way, and be treated like it has been disposed. No exceptions will be thrown for trying to free /// an object that does not belong to this pool. /// </summary> /// <param name="poolObject">The object to be freed.</param> /// <exception cref="ArgumentNullException"><paramref name="poolObject"/> is null.</exception> public void Free(PooledDbConnection poolObject) { _pool.Free(poolObject); }
/// <summary> /// Performs the initialization of a <see cref="PooledDbConnection"/> as it is grabbed from the object pool. /// </summary> /// <param name="conn">The <see cref="PooledDbConnection"/> to initialize.</param> protected virtual void InitializePooledConnection(PooledDbConnection conn) { if (conn.Connection.State != ConnectionState.Open) conn.Connection.Open(); }