Exemple #1
0
        private IPhysicalConnection _OpenCore(IPhysicalConnectionFactory fact, bool keepAlive, bool incref, bool open)
        {
            if (fact == null)
            {
                return(null);
            }
            string key = fact.GetConnectionKey();
            IPhysicalConnection res;

            lock (m_connCache)
            {
                if (!m_connCache.ContainsKey(key))
                {
                    var item = new CacheItem();
                    item.Connection = fact.CreateConnection();
                    if (Cache != null)
                    {
                        // use shared cache
                        item.Connection.Cache = Cache.Connection(key);
                    }
                    item.Connection.Owner = this;
                    m_connCache[key]      = item;
                }
                if (incref)
                {
                    m_connCache[key].RefCount++;
                }
                if (keepAlive)
                {
                    m_connCache[key].KeepAlive = true;
                }
                res = m_connCache[key].Connection;
            }
            if (open)
            {
                Async.SafeOpen(res);
            }
            return(res);
        }
Exemple #2
0
 // constructor 3'
 public DbDefSource(IPhysicalConnectionFactory fact, ReadOnly flag)
 {
     m_conn           = (DbDefConnection)fact.CreateConnection();
     m_openedReadOnly = true;
 }