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); }
// 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 }
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 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; }
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; }
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); }
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); }
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; } } } }
// 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 }
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); } } }
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; } } }
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; }