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); }
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); }
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; }
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; }
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; }
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(); } }
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(); } }