forked from jetheredge/SquishIt
/
DebugStatusReader.cs
59 lines (50 loc) · 1.54 KB
/
DebugStatusReader.cs
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
using System;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
namespace SquishIt.Framework.Utilities
{
public class DebugStatusReader: IDebugStatusReader
{
private bool forceDebug = false;
private bool forceRelease = false;
public bool IsDebuggingEnabled()
{
if (forceDebug)
{
return true;
}
if (forceRelease)
{
return false;
}
if (HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled)
{
//check retail setting in machine.config
//Thanks Dave Ward! http://www.encosia.com
System.Configuration.Configuration machineConfig = ConfigurationManager.OpenMachineConfiguration();
var group = machineConfig.GetSectionGroup("system.web");
if (group != null)
{
var appSettingSection = (DeploymentSection)group.Sections["deployment"];
if (appSettingSection.Retail)
{
return false;
}
}
return true;
}
return false;
}
#region IDebugStatusReader Members
public void ForceDebug()
{
forceDebug = true;
}
public void ForceRelease()
{
forceRelease = true;
}
#endregion
}
}