public bool IsOpened(IPhysicalConnectionFactory fact) { string key = fact.GetConnectionKey(); lock (m_connCache) { var item = m_connCache[key]; return(item.Connection != null && item.Connection.IsOpened); } }
public void Close(IPhysicalConnectionFactory fact) { string key = fact.GetConnectionKey(); lock (m_connCache) { if (!m_connCache.ContainsKey(key)) { throw new InternalError("DAE-00029 Connection key not found"); } m_connCache[key].RefCount--; if (m_connCache[key].RefCount <= 0 && !m_connCache[key].KeepAlive) { Async.SafeClose(m_connCache[key].Connection); } } }
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); }