コード例 #1
0
        public DbConnection UseConnection(IConnectionUser user)
        {
            if (user == null)
            {
                throw Error.ArgumentNull("user");
            }
            if (this.connection.State == ConnectionState.Closed)
            {
                this.connection.Open();
                this.autoClose = true;
                this.AddInfoMessageHandler();
                if (System.Transactions.Transaction.Current != null)
                {
                    System.Transactions.Transaction.Current.TransactionCompleted += this.OnTransactionCompleted;
                }
            }
            if (this.transaction == null && System.Transactions.Transaction.Current != null &&
                System.Transactions.Transaction.Current != systemTransaction)
            {
                this.ClearConnection();
                systemTransaction = System.Transactions.Transaction.Current;
                this.connection.EnlistTransaction(System.Transactions.Transaction.Current);
            }

            if (this.users.Count == this.maxUsers)
            {
                this.BootUser(this.users[0]);
            }
            this.users.Add(user);
            return(this.connection);
        }
コード例 #2
0
 public DbConnection UseConnection(IConnectionUser user)
 {
     if (user == null)
     {
         throw Error.ArgumentNull("user");
     }
     if (connection.State == ConnectionState.Closed)
     {
         connection.Open();
         AutoClose = true;
         AddInfoMessageHandler();
         if (System.Transactions.Transaction.Current != null)
         {
             System.Transactions.Transaction.Current.TransactionCompleted += OnTransactionCompleted;
         }
     }
     if (((transaction == null) && (System.Transactions.Transaction.Current != null)) &&
         (System.Transactions.Transaction.Current != systemTransaction))
     {
         ClearConnection();
         systemTransaction = System.Transactions.Transaction.Current;
         connection.EnlistTransaction(System.Transactions.Transaction.Current);
     }
     if (users.Count == maxUsers)
     {
         BootUser(users[0]);
     }
     users.Add(user);
     return(connection);
 }
コード例 #3
0
        public DbConnection UseConnection(IConnectionUser user) {
            if (user == null) {
                throw Error.ArgumentNull("user");
            }
            if (this.connection.State == ConnectionState.Closed) {
                this.connection.Open();
                this.autoClose = true;
                this.AddInfoMessageHandler();
                if (System.Transactions.Transaction.Current != null) {
                    System.Transactions.Transaction.Current.TransactionCompleted += this.OnTransactionCompleted;
                }
            }
            if (this.transaction == null && System.Transactions.Transaction.Current != null &&
                        System.Transactions.Transaction.Current != systemTransaction) {
                this.ClearConnection();
                systemTransaction = System.Transactions.Transaction.Current;
                this.connection.EnlistTransaction(System.Transactions.Transaction.Current);
            }

            if (this.users.Count == this.maxUsers) {
                this.BootUser(this.users[0]);
            }
            this.users.Add(user);
            return this.connection;
        }
コード例 #4
0
 private void BootUser(IConnectionUser user) {
     bool saveAutoClose = this.autoClose;
     this.autoClose = false;
     int index = this.users.IndexOf(user);
     if (index >= 0) {
         this.users.RemoveAt(index);
     }
     user.CompleteUse();
     this.autoClose = saveAutoClose;
 }
コード例 #5
0
        private void BootUser(IConnectionUser user)
        {
            bool close = AutoClose;

            AutoClose = false;
            int index = users.IndexOf(user);

            if (index >= 0)
            {
                users.RemoveAt(index);
            }
            user.CompleteUse();
            AutoClose = close;
        }
コード例 #6
0
        private void BootUser(IConnectionUser user)
        {
            bool saveAutoClose = this.autoClose;

            this.autoClose = false;
            int index = this.users.IndexOf(user);

            if (index >= 0)
            {
                this.users.RemoveAt(index);
            }
            user.CompleteUse();
            this.autoClose = saveAutoClose;
        }
コード例 #7
0
        public void ReleaseConnection(IConnectionUser user)
        {
            if (user == null)
            {
                throw Error.ArgumentNull("user");
            }
            int index = this.users.IndexOf(user);

            if (index >= 0)
            {
                this.users.RemoveAt(index);
            }
            if (this.users.Count == 0 && this.autoClose && this.transaction == null && System.Transactions.Transaction.Current == null)
            {
                this.CloseConnection();
            }
        }
コード例 #8
0
        public void ReleaseConnection(IConnectionUser user)
        {
            if (user == null)
            {
                throw Error.ArgumentNull("user");
            }
            int index = users.IndexOf(user);

            if (index >= 0)
            {
                users.RemoveAt(index);
            }
            if (((users.Count == 0) && AutoClose) && ((transaction == null) &&
                                                      (System.Transactions.Transaction.Current == null)))
            {
                CloseConnection();
            }
        }
コード例 #9
0
 public void ReleaseConnection(IConnectionUser user) {
     if (user == null) {
         throw Error.ArgumentNull("user");
     }
     int index = this.users.IndexOf(user);
     if (index >= 0) {
         this.users.RemoveAt(index);
     }
     if (this.users.Count == 0 && this.autoClose && this.transaction == null && System.Transactions.Transaction.Current == null) {
         this.CloseConnection();
     }
 }