예제 #1
0
        internal static void RemoveFromProvider(string key, string providerName)
        {
            if (providerName == null)
            {
                return;
            }

            OutputCacheProviderCollection providers = Providers;
            OutputCacheProvider           provider;

            if (providers == null || providers.Count == 0)
            {
                provider = null;
            }
            else
            {
                provider = providers [providerName];
            }

            if (provider == null)
            {
                throw new ProviderException("Provider '" + providerName + "' was not found.");
            }

            provider.Remove(key);
        }
예제 #2
0
        // remove cache vary
        // remove entry
        internal static void Remove(String key, HttpContext context)
        {
            // we don't know if it's in the internal cache or
            // one of the providers.  If a context is given,
            // then we can narrow down to at most one provider.
            // If the context is null, then we don't know which
            // provider and we have to check all.

            HttpRuntime.CacheInternal.Remove(key);

            if (context == null)
            {
                // remove from all providers since we don't know which one it's in.
                OutputCacheProviderCollection providers = Providers;
                if (providers != null)
                {
                    foreach (OutputCacheProvider provider in providers)
                    {
                        provider.Remove(key);
                    }
                }
            }
            else
            {
                OutputCacheProvider provider = GetProvider(context);
                if (provider != null)
                {
                    provider.Remove(key);
                }
            }
#if DBG
            Debug.Trace("OutputCache", "Remove(" + key + ", context)");
#endif
        }
예제 #3
0
        static void Init()
        {
            if (initialized)
            {
                return;
            }

            lock (initLock) {
                if (initialized)
                {
                    return;
                }

                var cfg = WebConfigurationManager.GetWebApplicationSection("system.web/caching/outputCache") as OutputCacheSection;
                ProviderSettingsCollection cfgProviders = cfg.Providers;

                defaultProviderName = cfg.DefaultProviderName;
                if (cfgProviders != null && cfgProviders.Count > 0)
                {
                    var coll = new OutputCacheProviderCollection();

                    foreach (ProviderSettings ps in cfgProviders)
                    {
                        coll.Add(LoadProvider(ps));
                    }

                    coll.SetReadOnly();
                    providers = coll;
                }

                initialized = true;
            }
        }
예제 #4
0
 internal static void ThrowIfProviderNotFound(string providerName)
 {
     if (providerName != null)
     {
         OutputCacheProviderCollection providers = Providers;
         if ((providers == null) || (providers[providerName] == null))
         {
             throw new ProviderException(System.Web.SR.GetString("Provider_Not_Found", new object[] { providerName }));
         }
     }
 }
 internal OutputCacheProviderCollection CreateProviderCollection()
 {
     ProviderSettingsCollection configProviders = this.Providers;
     if ((configProviders == null) || (configProviders.Count == 0))
     {
         return null;
     }
     OutputCacheProviderCollection providers = new OutputCacheProviderCollection();
     ProvidersHelper.InstantiateProviders(configProviders, providers, typeof(OutputCacheProvider));
     providers.SetReadOnly();
     return providers;
 }
예제 #6
0
        internal static void ThrowIfProviderNotFound(String providerName)
        {
            // null means use default provider or internal cache
            if (providerName == null)
            {
                return;
            }
            OutputCacheProviderCollection providers = Providers;

            if (providers == null || providers[providerName] == null)
            {
                throw new ProviderException(SR.GetString(SR.Provider_Not_Found, providerName));
            }
        }
 internal OutputCacheProvider GetDefaultProvider(OutputCacheProviderCollection providers)
 {
     string defaultProviderName = this.DefaultProviderName;
     if (defaultProviderName == "AspNetInternalProvider")
     {
         return null;
     }
     OutputCacheProvider provider = (providers == null) ? null : providers[defaultProviderName];
     if (provider == null)
     {
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Def_provider_not_found"), base.ElementInformation.Properties["defaultProvider"].Source, base.ElementInformation.Properties["defaultProvider"].LineNumber);
     }
     return provider;
 }
예제 #8
0
        internal static void RemoveFromProvider(string key, string providerName)
        {
            if (providerName == null)
            {
                throw new ArgumentNullException("providerName");
            }
            OutputCacheProviderCollection providers = Providers;
            OutputCacheProvider           provider  = (providers == null) ? null : providers[providerName];

            if (provider == null)
            {
                throw new ProviderException(System.Web.SR.GetString("Provider_Not_Found", new object[] { providerName }));
            }
            provider.Remove(key);
        }
예제 #9
0
        internal static OutputCacheProvider GetProvider(string providerName)
        {
            if (String.IsNullOrEmpty(providerName))
            {
                return(null);
            }

            if (String.Compare(providerName, DEFAULT_PROVIDER_NAME, StringComparison.Ordinal) == 0)
            {
                return(DefaultProvider);
            }

            OutputCacheProviderCollection providers = OutputCache.Providers;

            return(providers != null ? providers [providerName] : null);
        }
예제 #10
0
 private static void EnsureInitialized()
 {
     if (!s_inited)
     {
         lock (s_initLock)
         {
             if (!s_inited)
             {
                 OutputCacheSection outputCache = RuntimeConfig.GetAppConfig().OutputCache;
                 s_providers                            = outputCache.CreateProviderCollection();
                 s_defaultProvider                      = outputCache.GetDefaultProvider(s_providers);
                 s_entryRemovedCallback                 = new CacheItemRemovedCallback(OutputCache.EntryRemovedCallback);
                 s_dependencyRemovedCallback            = new CacheItemRemovedCallback(OutputCache.DependencyRemovedCallback);
                 s_dependencyRemovedCallbackForFragment = new CacheItemRemovedCallback(OutputCache.DependencyRemovedCallbackForFragment);
                 s_inited = true;
             }
         }
     }
 }
예제 #11
0
        // remove cache vary
        // remove entry
        internal static void RemoveFromProvider(String key, String providerName)
        {
            // we know where it is.  If providerName is given,
            // then it is in that provider.  If it's not given,
            // it's in the internal cache.
            if (providerName == null)
            {
                throw new ArgumentNullException("providerName");
            }

            OutputCacheProviderCollection providers = Providers;
            OutputCacheProvider           provider  = (providers == null) ? null : providers[providerName];

            if (provider == null)
            {
                throw new ProviderException(SR.GetString(SR.Provider_Not_Found, providerName));
            }

            provider.Remove(key);
#if DBG
            Debug.Trace("OutputCache", "Remove(" + key + ", " + providerName + ")");
#endif
        }
예제 #12
0
 internal static void Remove(string key, HttpContext context)
 {
     HttpRuntime.CacheInternal.Remove(key);
     if (context == null)
     {
         OutputCacheProviderCollection providers = Providers;
         if (providers != null)
         {
             foreach (OutputCacheProvider provider in providers)
             {
                 provider.Remove(key);
             }
         }
     }
     else
     {
         OutputCacheProvider provider2 = GetProvider(context);
         if (provider2 != null)
         {
             provider2.Remove(key);
         }
     }
 }
예제 #13
0
        private static void EnsureInitialized() {
            if (s_inited) 
                return;

            lock (s_initLock) {
                if (!s_inited) {
                    OutputCacheSection settings = RuntimeConfig.GetAppConfig().OutputCache;
                    s_providers = settings.CreateProviderCollection();
                    s_defaultProvider = settings.GetDefaultProvider(s_providers);
                    s_entryRemovedCallback = new CacheItemRemovedCallback(OutputCache.EntryRemovedCallback);
                    s_dependencyRemovedCallback = new CacheItemRemovedCallback(OutputCache.DependencyRemovedCallback);
                    s_dependencyRemovedCallbackForFragment = new CacheItemRemovedCallback(OutputCache.DependencyRemovedCallbackForFragment);
                    s_inited = true;
                }
            }
        }
예제 #14
0
파일: OutputCache.cs 프로젝트: kumpera/mono
		static void Init ()
		{
			if (initialized)
				return;

			lock (initLock) {
				if (initialized)
					return;
				
				var cfg = WebConfigurationManager.GetWebApplicationSection ("system.web/caching/outputCache") as OutputCacheSection;
				ProviderSettingsCollection cfgProviders = cfg.Providers;

				defaultProviderName = cfg.DefaultProviderName;
				if (cfgProviders != null && cfgProviders.Count > 0) {
					var coll = new OutputCacheProviderCollection ();

					foreach (ProviderSettings ps in cfgProviders)
						coll.Add (LoadProvider (ps));

					coll.SetReadOnly ();
					providers = coll;
				}

				initialized = true;
			}
		}
        internal OutputCacheProvider GetDefaultProvider(OutputCacheProviderCollection providers) {
            // if defaultProvider is undefined, we'll default to the v2.0 OutputCache
            string defaultProviderName = DefaultProviderName;
            if (defaultProviderName == OutputCache.ASPNET_INTERNAL_PROVIDER_NAME) {
                return null;
            }

            // if the defaultProvider is defined, it must be in the providers collection
            OutputCacheProvider defaultProvider = (providers == null) ? null : providers[defaultProviderName];
            if (defaultProvider == null) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Def_provider_not_found),
                                                       ElementInformation.Properties["defaultProvider"].Source,
                                                       ElementInformation.Properties["defaultProvider"].LineNumber);
            }
            return defaultProvider;
        }
 internal OutputCacheProviderCollection CreateProviderCollection() {
     // if there are no providers defined, we'll default to the v2.0 OutputCache
     ProviderSettingsCollection providers = Providers;
     if (providers == null || providers.Count == 0) {
         return null;
     }
     OutputCacheProviderCollection collection = new OutputCacheProviderCollection();
     ProvidersHelper.InstantiateProviders(providers, collection, typeof(OutputCacheProvider));
     collection.SetReadOnly();
     return collection;
 }