Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs')
-rw-r--r--mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs85
1 files changed, 27 insertions, 58 deletions
diff --git a/mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs b/mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs
index 9a24a5b37f2..344b260760a 100644
--- a/mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs
+++ b/mcs/class/referencesource/System.Web/Hosting/ApplicationManager.cs
@@ -9,7 +9,9 @@ namespace System.Web.Hosting {
using System;
using System.Collections;
using System.Collections.Generic;
+ using System.Collections.Specialized;
using System.Configuration;
+ using System.Configuration.Provider;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
@@ -88,9 +90,6 @@ namespace System.Web.Hosting {
// single instance of app manager
private static ApplicationManager _theAppManager;
- // single instance of cache manager
- private static CacheManager _cm;
-
// store fatal exception to assist debugging
private static Exception _fatalException = null;
@@ -105,52 +104,6 @@ namespace System.Web.Hosting {
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
}
- private void InitCacheManager(long privateBytesLimit) {
- if (_cm == null) {
- lock (_applicationManagerStaticLock) {
- if (_cm == null && !_shutdownInProgress) {
- _cm = new CacheManager(this, privateBytesLimit);
- }
- }
- }
- }
-
- private void DisposeCacheManager() {
- if (_cm != null) {
- lock (_applicationManagerStaticLock) {
- if (_cm != null) {
- _cm.Dispose();
- _cm = null;
- }
- }
- }
- }
-
- // Each cache must update the total with the difference between it's current size and it's previous size.
- // To reduce cross-domain costs, this also returns the updated total size.
- internal long GetUpdatedTotalCacheSize(long sizeUpdate) {
- CacheManager cm = _cm;
- return (cm != null) ? cm.GetUpdatedTotalCacheSize(sizeUpdate) : 0;
- }
-
- internal long TrimCaches(int percent) {
- long trimmedOrExpired = 0;
- Dictionary<string, LockableAppDomainContext> apps = CloneAppDomainsCollection();
- foreach (LockableAppDomainContext ac in apps.Values) {
- lock (ac) {
- HostingEnvironment env = ac.HostEnv;
- if (_shutdownInProgress) {
- break;
- }
- if (env == null) {
- continue;
- }
- trimmedOrExpired += env.TrimCache(percent);
- }
- }
- return trimmedOrExpired;
- }
-
internal bool ShutdownInProgress {
get {
return _shutdownInProgress;
@@ -468,6 +421,10 @@ namespace System.Web.Hosting {
return GetAppDomain(appID);
}
+ internal AppDomain GetDefaultAppDomain() {
+ return AppDomain.CurrentDomain;
+ }
+
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "This isn't a dangerous method.")]
private string CreateSimpleAppID(IApplicationHost appHost) {
if (appHost == null) {
@@ -565,8 +522,6 @@ namespace System.Web.Hosting {
_shutdownInProgress = true;
Dictionary <string, LockableAppDomainContext> oldTable = null;
- DisposeCacheManager();
-
lock (this) {
oldTable = _appDomains;
// don't keep references to hosting environments anymore
@@ -769,13 +724,8 @@ namespace System.Web.Hosting {
// communication with hosting environments
//
- internal void HostingEnvironmentActivated(long privateBytesLimit) {
+ internal void HostingEnvironmentActivated() {
int count = Interlocked.Increment(ref _activeHostingEnvCount);
-
- // initialize CacheManager once, without blocking
- if (count == 1) {
- InitCacheManager(privateBytesLimit);
- }
}
internal void HostingEnvironmentShutdownComplete(String appId, IApplicationHost appHost) {
@@ -1021,7 +971,7 @@ namespace System.Web.Hosting {
//Hosted by IIS, we already have an IISMap.
if (appHost is ISAPIApplicationHost) {
string cacheKey = System.Web.Caching.CacheInternal.PrefixMapPath + siteID + virtualPath.VirtualPathString;
- MapPathCacheInfo cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Remove(cacheKey);
+ MapPathCacheInfo cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Remove(cacheKey);
appConfig = WebConfigurationManager.OpenWebConfiguration(appSegment, siteID);
}
// For non-IIS hosting scenarios, we need to get config map from application host in a generic way.
@@ -1117,6 +1067,25 @@ namespace System.Web.Hosting {
}
}
+ // Allow apps to use their own CacheStoreProvider implementations
+ CacheSection cacheConfig = (CacheSection)appConfig.GetSection("system.web/caching/cache");
+ if (cacheConfig != null && cacheConfig.DefaultProvider != null && !String.IsNullOrWhiteSpace(cacheConfig.DefaultProvider)) {
+ ProviderSettingsCollection cacheProviders = cacheConfig.Providers;
+ if (cacheProviders == null || cacheProviders.Count < 1) {
+ throw new ProviderException(SR.GetString(SR.Def_provider_not_found));
+ }
+
+ ProviderSettings cacheProviderSettings = cacheProviders[cacheConfig.DefaultProvider];
+ if (cacheProviderSettings == null) {
+ throw new ProviderException(SR.GetString(SR.Def_provider_not_found));
+ } else {
+ NameValueCollection settings = cacheProviderSettings.Parameters;
+ settings["name"] = cacheProviderSettings.Name;
+ settings["type"] = cacheProviderSettings.Type;
+ appDomainAdditionalData[".defaultObjectCacheProvider"] = settings;
+ }
+ }
+
// If we were launched from a development environment, we might want to enable the application to do things
// it otherwise wouldn't normally allow, such as enabling an administrative control panel. For security reasons,
// we only do this check if <deployment retail="false" /> [the default value] is specified, since the