コード例 #1
0
        public IPooledConnection CreateNewPooledConnection()
        {
            PooledConnection conn = null;

            try
            {
                _statistics?.IncrementConnectionToCreate();

                conn = _fakeConnection != null
                    ? new PooledConnection(_fakeConnection, Release)
                    : new PooledConnection(new SocketConnection(_uri, _connectionSettings, _logger), Release);
                conn.Init();

                _statistics?.IncrementConnectionCreated();
                return(conn);
            }
            catch
            {
                _statistics?.IncrementConnectionFailedToCreate();

                // shut down and clean all the resources of the conneciton if failed to establish
                if (conn != null)
                {
                    CloseConnection(conn);
                }
                throw;
            }
        }