Beispiel #1
0
        /// <summary>
        /// If available, returns the requested connection from the _connectionTable.
        /// Otherwise, returns null.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public object RemoveResource(object key)
        {
            ResourceInfo resourceInfo = resourceTable[key] as ResourceInfo;

            if (resourceInfo != null)
            {
                if (resourceInfo.Release() == 0)
                {
                    resourceTable.Remove(key);
                    DisposeResource(resourceInfo.Object);
                }
                return(resourceInfo.Object);
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Remove o recurso associado com a chave informada.
        /// </summary>
        /// <param name="key">Chave que representa o recuros.</param>
        /// <returns>Instancia do recurso removido.</returns>
        public object RemoveResource(object key)
        {
            ResourceInfo info = _resourceTable[key] as ResourceInfo;

            if (info == null)
            {
                return(null);
            }
            if (info.Release() == 0)
            {
                _resourceTable.Remove(key);
                DisposeResource(info.Object);
            }
            return(info.Object);
        }
Beispiel #3
0
        public object RemoveResource(object key, int numberOfCallbacks)
        {
            ResourceInfo resourceInfo = resourceTable[key] as ResourceInfo;

            if (resourceInfo != null)
            {
                for (int i = 0; i < numberOfCallbacks; i++)
                {
                    if (resourceInfo.Release() == 0)
                    {
                        resourceTable.Remove(key);
                        DisposeResource(resourceInfo.Object);
                    }
                }
                return(resourceInfo.Object);
            }
            return(null);
        }