コード例 #1
0
            }             // func FindPooledConnection

            internal IPpsConnectionHandle GetOrCreatePooledConnection(PpsDataSource dataSource, IPpsPrivateDataContext userData, bool throwException)
            {
                lock (pooledConnections)
                {
                    var pooled = FindPooledConnection(dataSource);
                    if (pooled == null)
                    {
                        var handle = dataSource.CreateConnection(userData, throwException);
                        if (handle == null)
                        {
                            return(null);
                        }

                        pooledConnections.Add(new PooledConnection(handle));

                        Log.Info("New pooled connection: {0}", dataSource.Name);
                        return(handle);
                    }
                    else
                    {
                        //Log.Info("Reuse pooled connection: {0}", dataSource.Name);
                        return(pooled.Handle);
                    }
                }
            }             // func GetOrCreatePooledConnection
コード例 #2
0
            }             // class PpsStringJoinExpression

            #endregion

            public async Task <IPpsConnectionHandle> EnsureConnectionAsync(PpsDataSource source, bool throwException)
            {
                var c = privateUser.GetOrCreatePooledConnection(source, this, throwException);

                if (c == null)
                {
                    c = source.CreateConnection(this, throwException);
                }

                return(c != null && await c.EnsureConnectionAsync(throwException) ? c : null);
            }             // func EnsureConnection