1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
//------------------------------------------------------------------------------
// <copyright file="ScriptingScriptResourceHandlerSection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.Configuration {
using System;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.Script.Serialization;
public sealed class ScriptingScriptResourceHandlerSection : ConfigurationSection {
private static readonly ConfigurationProperty _propEnableCaching =
new ConfigurationProperty("enableCaching",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEnableCompression =
new ConfigurationProperty("enableCompression",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static ConfigurationPropertyCollection _properties = BuildProperties();
private static ConfigurationPropertyCollection BuildProperties() {
ConfigurationPropertyCollection props = new ConfigurationPropertyCollection();
props.Add(_propEnableCaching);
props.Add(_propEnableCompression);
return props;
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("enableCaching", DefaultValue = true)]
public bool EnableCaching {
get {
return (bool)base[_propEnableCaching];
}
set {
base[_propEnableCaching] = value;
}
}
[ConfigurationProperty("enableCompression", DefaultValue = true)]
public bool EnableCompression {
get {
return (bool)base[_propEnableCompression];
}
set {
base[_propEnableCompression] = value;
}
}
internal static class ApplicationSettings {
private volatile static bool s_sectionLoaded;
private static bool s_enableCaching;
private static bool s_enableCompression;
private static void EnsureSectionLoaded() {
if (!s_sectionLoaded) {
ScriptingScriptResourceHandlerSection section = (ScriptingScriptResourceHandlerSection)
WebConfigurationManager.GetWebApplicationSection("system.web.extensions/scripting/scriptResourceHandler");
if (section != null) {
s_enableCaching = section.EnableCaching;
s_enableCompression = section.EnableCompression;
}
else {
s_enableCaching = (bool)_propEnableCaching.DefaultValue;
s_enableCompression = (bool)_propEnableCompression.DefaultValue;
}
s_sectionLoaded = true;
}
}
internal static bool EnableCaching {
get {
EnsureSectionLoaded();
return s_enableCaching;
}
}
internal static bool EnableCompression {
get {
EnsureSectionLoaded();
return s_enableCompression;
}
}
}
}
}
|