예제 #1
0
 /// <summary>
 /// Libera a instancia.
 /// </summary>
 /// <param name="disposing"></param>
 protected override void Dispose(bool disposing)
 {
     if (_storage != null)
     {
         _storage.Dispose();
         _storage = null;
     }
     base.Dispose(disposing);
 }
예제 #2
0
        public static ICacheStorage CreateStorageProvider(IDictionary properties, string cacheContext, bool evictionEnabled, ILogger logger)
        {
            properties.Require("properties").NotNull();
            StorageProviderBase base2 = null;

            try
            {
                if (!properties.Contains("class"))
                {
                    throw new ConfigurationException(ResourceMessageFormatter.Create(() => Properties.Resources.ConfigurationException_MissingCacheStorageClass).Format());
                }
                string      str        = Convert.ToString(properties["class"]).ToLower();
                IDictionary dictionary = (IDictionary)properties[str];
                if (str.CompareTo("heap") == 0)
                {
                    base2 = new ClrHeapStorageProvider(dictionary, evictionEnabled, logger);
                }
                else if (str.CompareTo("memory") == 0)
                {
                    base2 = new InMemoryStorageProvider(dictionary, evictionEnabled);
                }
                else if (str.CompareTo("memory-mapped") == 0)
                {
                    base2 = new MmfStorageProvider(dictionary, evictionEnabled);
                }
                else
                {
                    if (str.CompareTo("file") != 0)
                    {
                        throw new ConfigurationException(ResourceMessageFormatter.Create(() => Properties.Resources.ConfigurationException_InvalidCacheStorageClass, str).Format());
                    }
                    base2 = new FileSystemStorageProvider(dictionary, evictionEnabled);
                }
                if (base2 != null)
                {
                    base2.CacheContext = cacheContext;
                }
            }
            catch (ConfigurationException exception)
            {
                Trace.Error("CacheStorageFactory.CreateCacheStore()".GetFormatter(), exception.GetFormatter());
                throw;
            }
            catch (Exception exception2)
            {
                Trace.Error("CacheStorageFactory.CreateCacheStore()".GetFormatter(), exception2.GetFormatter());
                throw new ConfigurationException("Configuration Error: " + exception2.ToString(), exception2);
            }
            return(base2);
        }
예제 #3
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="storageProvider">Instancia que será adaptada.</param>
 public StorageProviderSyncWrapper(StorageProviderBase storageProvider)
 {
     storageProvider.Require("storageProvider").NotNull();
     _storage      = storageProvider;
     base._syncObj = _storage.Sync;
 }
예제 #4
0
 /// <summary>
 /// Recupera um provedor sincronizado.
 /// </summary>
 /// <param name="cacheStorage"></param>
 /// <returns></returns>
 public static StorageProviderBase Synchronized(StorageProviderBase cacheStorage)
 {
     return(new StorageProviderSyncWrapper(cacheStorage));
 }