Profiler can be enabled via config file.

This commit is contained in:
Mark McDowall 2011-12-13 18:31:20 -08:00
parent f56bf62991
commit 28259bc254
5 changed files with 29 additions and 2 deletions

View File

@ -62,6 +62,12 @@ namespace NzbDrone.Common
set { SetValue("AuthenticationType", (int)value); }
}
public virtual bool EnableProfiler
{
get { return GetValueBoolean("EnableProfiler", false); }
set { SetValue("EnableProfiler", value); }
}
public virtual int GetValueInt(string key, int defaultValue)
{
return Convert.ToInt32(GetValue(key, defaultValue));

View File

@ -5,6 +5,7 @@ using MvcMiniProfiler;
using MvcMiniProfiler.MVCHelpers;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using NzbDrone.Common;
using NzbDrone.Web.Helpers;
//using System.Data;
//using System.Data.Entity;
@ -69,7 +70,7 @@ namespace NzbDrone.Web.App_Start
// so authenticated users are always profiled
//if (request.IsLocal) { MiniProfiler.Start(); }
if (!EnviromentProvider.IsProduction)
if (!EnviromentProvider.IsProduction || ProfilerHelper.Enabled())
{
MiniProfiler.Start();
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Common;
namespace NzbDrone.Web.Helpers
{
public static class ProfilerHelper
{
public static bool Enabled()
{
var enviromentProvider = new EnviromentProvider();
var configFileProvider = new ConfigFileProvider(enviromentProvider);
return configFileProvider.EnableProfiler;
}
}
}

View File

@ -219,6 +219,7 @@
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Helpers\HtmlIncludeExtentions.cs" />
<Compile Include="Helpers\ProfilerHelper.cs" />
<Compile Include="Helpers\ValueExtension.cs" />
<Compile Include="Helpers\DescriptionExtension.cs" />
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />

View File

@ -13,7 +13,7 @@
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
}
<title>@ViewBag.Title</title>
@if (!EnviromentProvider.IsProduction)
@if (!EnviromentProvider.IsProduction || ProfilerHelper.Enabled())
{
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
}