コード例 #1
0
        public void MultipleDisposesCleanupMultipleAddRefs()
        {
            // Start at refcount 1
            var wrapper = new DatabaseConnectionWrapper(connection);

            wrapper.AddRef();
            wrapper.AddRef();

            wrapper.Dispose();
            AssertNotDisposed(wrapper);

            wrapper.Dispose();
            AssertNotDisposed(wrapper);

            wrapper.Dispose();
            AssertDisposed(wrapper);
        }
コード例 #2
0
        public void MultipleDisposesCleanupMultipleAddRefs()
        {
            // Start at refcount 1
            var wrapper = new DatabaseConnectionWrapper(connection);

            wrapper.AddRef();
            wrapper.AddRef();

            wrapper.Dispose();
            AssertNotDisposed(wrapper);

            wrapper.Dispose();
            AssertNotDisposed(wrapper);

            wrapper.Dispose();
            AssertDisposed(wrapper);
        }
コード例 #3
0
        public void AddRefRequiresExtraClose()
        {
            var wrapper = new DatabaseConnectionWrapper(connection);
            using(wrapper.AddRef())
            {
            }

            AssertNotDisposed(wrapper);
        }
コード例 #4
0
 /// <summary>
 ///        <para>Creates a connection for this database.</para>
 /// </summary>
 /// <remarks>
 ///        This method has been overridden to support keeping a single connection open until you
 ///        explicitly close it with a call to <see cref="CloseSharedConnection"/>.
 /// </remarks>
 /// <returns>
 ///        <para>The <see cref="DbConnection"/> for this database.</para>
 /// </returns>
 /// <seealso cref="DbConnection"/>
 public override DbConnection CreateConnection()
 {
     using (DatabaseConnectionWrapper wrapper = SqlCeConnectionPool.CreateConnection(this))
     {
         wrapper.AddRef();
         wrapper.Connection.ConnectionString = ConnectionString;
         return(wrapper.Connection);
     }
 }
コード例 #5
0
        public void AddRefRequiresExtraClose()
        {
            var wrapper = new DatabaseConnectionWrapper(connection);

            using (wrapper.AddRef())
            {
            }

            AssertNotDisposed(wrapper);
        }
コード例 #6
0
        /// <summary>
        ///		Gets a "wrapped" connection that will be not be disposed if a transaction is
        ///		active (created by creating a <see cref="TransactionScope"/> instance). The
        ///		connection will be disposed when no transaction is active.
        /// </summary>
        /// <returns></returns>
        protected override DatabaseConnectionWrapper GetOpenConnection()
        {
            DatabaseConnectionWrapper connection = TransactionScopeConnections.GetConnection(this);

            if (connection != null)
            {
                connection.AddRef();
            }
            return(connection ?? GetWrappedConnection());
        }
コード例 #7
0
 internal RefCountingOracleDataReaderWrapper(DatabaseConnectionWrapper connection, OracleDataReader innerReader)
     : base(innerReader)
 {
     _connection = connection;
     _connection.AddRef();
 }