You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@ -19,14 +19,20 @@ namespace System.Web.Configuration {
|
||||
/*
|
||||
<!--
|
||||
cache Attributes:
|
||||
defaultProvider="name" - a name matching a provider in the provider list to use for Object and Internal cache.
|
||||
cacheAPIEnabled="[true|false]" - Enable or disable the user Cache API
|
||||
disableMemoryCollection="[true|false]" - Enable or disable the cache memory collection
|
||||
disableExpiration="[true|false]" - Enable or disable the expiration of items from the cache
|
||||
privateBytesLimit="number" - Represents maximum private bytes (in bytes) allowed. If it's zero, Cache will use an auto-generated limit. Cache will collect memory when the private bytes is near the limit. This works on top of other memory indexes monitored by Cache.
|
||||
percentagePhysicalMemoryUsedLimit="number" - Represents percentage of physical memory process allowed. Cache will collect memory when the private bytes is near the limit. This works on top of other memory indexes monitored by Cache.
|
||||
privateBytesPollTime="timespan" - How often we poll the process memory by calling NtQuerySystemInformation. Default is 2 min.
|
||||
|
||||
-->
|
||||
<cache cacheAPIEnabled="true" />
|
||||
<cache cacheAPIEnabled="true" defaultProvider="name" >
|
||||
<providers>
|
||||
<add name="string" type="string" ... />
|
||||
</providers>
|
||||
</cache>
|
||||
*/
|
||||
|
||||
public sealed class CacheSection : ConfigurationSection {
|
||||
@ -44,6 +50,9 @@ namespace System.Web.Configuration {
|
||||
private static readonly ConfigurationProperty _propPercentagePhysicalMemoryUsedLimit;
|
||||
private static readonly ConfigurationProperty _propPrivateBytesPollTime;
|
||||
|
||||
private static readonly ConfigurationProperty _propProviders;
|
||||
private static readonly ConfigurationProperty _propDefaultProvider;
|
||||
|
||||
|
||||
static CacheSection() {
|
||||
// Property initialization
|
||||
@ -51,6 +60,14 @@ namespace System.Web.Configuration {
|
||||
_propCacheAPIEnabled = new ConfigurationProperty("cacheAPIEnabled", typeof(bool), true, ConfigurationPropertyOptions.None);
|
||||
_propDisableDependencies = new ConfigurationProperty("disableDependencies", typeof(bool), false, ConfigurationPropertyOptions.None);
|
||||
#endif
|
||||
_propProviders = new ConfigurationProperty("providers", typeof(ProviderSettingsCollection), null, ConfigurationPropertyOptions.None);
|
||||
_propDefaultProvider =
|
||||
new ConfigurationProperty("defaultProvider",
|
||||
typeof(string),
|
||||
null,
|
||||
null,
|
||||
StdValidatorsAndConverters.NonEmptyStringValidator,
|
||||
ConfigurationPropertyOptions.None);
|
||||
|
||||
_propDisableMemoryCollection =
|
||||
new ConfigurationProperty("disableMemoryCollection",
|
||||
@ -91,6 +108,8 @@ namespace System.Web.Configuration {
|
||||
_properties.Add(_propDisableDependencies);
|
||||
#endif
|
||||
|
||||
_properties.Add(_propProviders);
|
||||
_properties.Add(_propDefaultProvider);
|
||||
_properties.Add(_propDisableMemoryCollection);
|
||||
_properties.Add(_propDisableExpiration);
|
||||
_properties.Add(_propPrivateBytesLimit);
|
||||
@ -101,6 +120,24 @@ namespace System.Web.Configuration {
|
||||
public CacheSection() {
|
||||
}
|
||||
|
||||
[ConfigurationProperty("providers")]
|
||||
public ProviderSettingsCollection Providers {
|
||||
get {
|
||||
return (ProviderSettingsCollection)base[_propProviders];
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("defaultProvider", DefaultValue = null)]
|
||||
[StringValidator(MinLength = 1)]
|
||||
public string DefaultProvider {
|
||||
get {
|
||||
return (string)base[_propDefaultProvider];
|
||||
}
|
||||
set {
|
||||
base[_propDefaultProvider] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#if NOT_UNTIL_LATER
|
||||
[ConfigurationProperty("cacheAPIEnabled", DefaultValue = true)]
|
||||
public bool CacheAPIEnabled
|
||||
|
@ -15,6 +15,7 @@ namespace System.Web.Configuration {
|
||||
using System.Web.Compilation;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Web;
|
||||
|
||||
/*
|
||||
* An object to cache a factory
|
||||
@ -37,6 +38,7 @@ namespace System.Web.Configuration {
|
||||
else {
|
||||
throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
|
||||
}
|
||||
TelemetryLogger.LogHttpHandler(instance.GetType());
|
||||
}
|
||||
|
||||
internal HandlerFactoryCache(HttpHandlerAction mapping) {
|
||||
@ -54,6 +56,7 @@ namespace System.Web.Configuration {
|
||||
else {
|
||||
throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
|
||||
}
|
||||
TelemetryLogger.LogHttpHandler(instance.GetType());
|
||||
}
|
||||
|
||||
internal IHttpHandlerFactory Factory {
|
||||
|
@ -211,7 +211,7 @@ namespace System.Web.Configuration {
|
||||
private void CacheBrowserCapResult(ref HttpCapabilitiesBase result) {
|
||||
// Use the previously cached browserCap object if an identical
|
||||
// browserCap is found.
|
||||
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
|
||||
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
|
||||
|
||||
if (result.Capabilities == null) {
|
||||
return;
|
||||
@ -241,7 +241,7 @@ namespace System.Web.Configuration {
|
||||
}
|
||||
else {
|
||||
// cache it and respect cachetime
|
||||
cacheInternal.UtcInsert(hashKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
|
||||
cacheInternal.Insert(hashKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ namespace System.Web.Configuration {
|
||||
internal HttpCapabilitiesBase Evaluate(HttpRequest request) {
|
||||
|
||||
HttpCapabilitiesBase result;
|
||||
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
|
||||
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
|
||||
|
||||
//
|
||||
// 1) grab UA and do optimistic cache lookup (if UA is in dependency list)
|
||||
@ -298,7 +298,7 @@ namespace System.Web.Configuration {
|
||||
CacheBrowserCapResult(ref result);
|
||||
|
||||
// Cache the result using the optimisicCacheKey
|
||||
cacheInternal.UtcInsert(optimisticCacheKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
|
||||
cacheInternal.Insert(optimisticCacheKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -363,9 +363,9 @@ namespace System.Web.Configuration {
|
||||
CacheBrowserCapResult(ref result);
|
||||
|
||||
// cache it and respect _cachetime
|
||||
cacheInternal.UtcInsert(fullCacheKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
|
||||
cacheInternal.Insert(fullCacheKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
|
||||
if(optimisticCacheKey != null) {
|
||||
cacheInternal.UtcInsert(optimisticCacheKey, _disableOptimisticCachingSingleton, null, Cache.NoAbsoluteExpiration, _cachetime);
|
||||
cacheInternal.Insert(optimisticCacheKey, _disableOptimisticCachingSingleton, new CacheInsertOptions() { SlidingExpiration = _cachetime });
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -226,7 +226,7 @@ namespace System.Web.Configuration {
|
||||
else {
|
||||
// Check if it's in the cache
|
||||
String cacheKey = CacheInternal.PrefixMapPath + siteID + path.VirtualPathString;
|
||||
cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Get(cacheKey);
|
||||
cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Get(cacheKey);
|
||||
|
||||
// If not in cache, add it to the cache
|
||||
if (cacheInfo == null) {
|
||||
@ -234,8 +234,7 @@ namespace System.Web.Configuration {
|
||||
// Add to the cache.
|
||||
// No need to have a lock here. UtcAdd will add the entry if it doesn't exist.
|
||||
// If it does exist, the existing value will be returned (Dev10 Bug 755034).
|
||||
object existingEntry = HttpRuntime.CacheInternal.UtcAdd(
|
||||
cacheKey, cacheInfo, null, Cache.NoAbsoluteExpiration, slidingExpiration, CacheItemPriority.Default, null);
|
||||
object existingEntry = HttpRuntime.Cache.InternalCache.Add(cacheKey, cacheInfo, new CacheInsertOptions() { SlidingExpiration = slidingExpiration });
|
||||
if (existingEntry != null) {
|
||||
cacheInfo = existingEntry as MapPathCacheInfo;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ namespace System.Web.Configuration {
|
||||
else {
|
||||
// Check if it's in the cache
|
||||
String cacheKey = CacheInternal.PrefixMapPath + siteID + path.VirtualPathString;
|
||||
cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Get(cacheKey);
|
||||
cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Get(cacheKey);
|
||||
|
||||
// If not in cache, add it to the cache
|
||||
if (cacheInfo == null) {
|
||||
@ -232,8 +232,7 @@ namespace System.Web.Configuration {
|
||||
// Add to the cache.
|
||||
// No need to have a lock here. UtcAdd will add the entry if it doesn't exist.
|
||||
// If it does exist, the existing value will be returned (Dev10 Bug 755034).
|
||||
object existingEntry = HttpRuntime.CacheInternal.UtcAdd(
|
||||
cacheKey, cacheInfo, null, Cache.NoAbsoluteExpiration, slidingExpiration, CacheItemPriority.Default, null);
|
||||
object existingEntry = HttpRuntime.Cache.InternalCache.Add(cacheKey, cacheInfo, new CacheInsertOptions() { SlidingExpiration = slidingExpiration });
|
||||
if (existingEntry != null) {
|
||||
cacheInfo = existingEntry as MapPathCacheInfo;
|
||||
}
|
||||
|
@ -46,6 +46,35 @@ namespace System.Web.Configuration
|
||||
return provider;
|
||||
}
|
||||
|
||||
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)]
|
||||
internal static ProviderBase InstantiateProvider(NameValueCollection providerSettings, Type providerType) {
|
||||
ProviderBase provider = null;
|
||||
try {
|
||||
string pnName = GetAndRemoveStringValue(providerSettings, "name");
|
||||
string pnType = GetAndRemoveStringValue(providerSettings, "type");
|
||||
if (string.IsNullOrEmpty(pnType))
|
||||
throw new ArgumentException(SR.GetString(SR.Provider_no_type_name));
|
||||
Type t = ConfigUtil.GetType(pnType, "type", null, null, true, true);
|
||||
|
||||
if (!providerType.IsAssignableFrom(t))
|
||||
throw new ArgumentException(SR.GetString(SR.Provider_must_implement_type, providerType.ToString()));
|
||||
provider = (ProviderBase)HttpRuntime.CreatePublicInstance(t);
|
||||
|
||||
// Because providers modify the parameters collection (i.e. delete stuff), pass in a clone of the collection
|
||||
NameValueCollection cloneParams = new NameValueCollection(providerSettings.Count, StringComparer.Ordinal);
|
||||
foreach (string key in providerSettings)
|
||||
cloneParams[key] = providerSettings[key];
|
||||
provider.Initialize(pnName, cloneParams);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e is ConfigurationException)
|
||||
throw;
|
||||
throw new ConfigurationErrorsException(e.Message, e);
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)]
|
||||
public static void InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
|
||||
{
|
||||
@ -53,5 +82,13 @@ namespace System.Web.Configuration
|
||||
providers.Add(InstantiateProvider(ps, providerType));
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAndRemoveStringValue(NameValueCollection collection, string key) {
|
||||
string strValue = collection[key] as string;
|
||||
if (!string.IsNullOrEmpty(strValue))
|
||||
strValue = strValue.Trim();
|
||||
collection.Remove(key);
|
||||
return strValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ namespace System.Web.Configuration {
|
||||
return (string)base[_propLockAttributes];
|
||||
}
|
||||
set {
|
||||
// base.LockedAttributes.SetFromList(value); // keep the internal list in [....]
|
||||
// base.LockedAttributes.SetFromList(value); // keep the internal list in sync
|
||||
base[_propLockAttributes] = value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user