Xamarin Public Jenkins (auto-signing) e79aa3c0ed Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
2016-08-03 10:59:49 +00:00

51 lines
1.7 KiB
C#

//------------------------------------------------------------------------------
// <copyright file="AppLevelCompilationSectionCache.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI {
using System;
using System.Configuration;
using System.Security;
using System.Security.Permissions;
using System.Web.Configuration;
// The compilation section can be defined below the application level, but ScriptManager only considers the
// application-level debug setting.
internal sealed class AppLevelCompilationSectionCache : ICompilationSection {
private static readonly AppLevelCompilationSectionCache _instance = new AppLevelCompilationSectionCache();
// Value is cached statically, because AppLevelCompilationSectionCache is a Singleton.
private bool? _debug;
private AppLevelCompilationSectionCache() {
}
public static AppLevelCompilationSectionCache Instance {
get {
return _instance;
}
}
public bool Debug {
get {
if (_debug == null) {
_debug = GetDebugFromConfig();
}
return _debug.Value;
}
}
[
ConfigurationPermission(SecurityAction.Assert, Unrestricted = true),
SecuritySafeCritical(),
]
private static bool GetDebugFromConfig() {
CompilationSection section =
(CompilationSection)WebConfigurationManager.GetWebApplicationSection("system.web/compilation");
return section.Debug;
}
}
}