Changed the profiler over to use resolvers again. We no longer will call MiniProfiler directly.
Added an HtmlHelper extension which is used to render the profiler html output. Added an HtmlHelper property to the new base page too.
This commit is contained in:
@@ -187,6 +187,9 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
protected virtual void InitializeResolvers()
|
||||
{
|
||||
//By default we'll initialize the Log profiler (in the web project, we'll override with the web profiler)
|
||||
ProfilerResolver.Current = new ProfilerResolver(new LogProfiler());
|
||||
|
||||
//by default we'll use the standard configuration based sync
|
||||
ServerRegistrarResolver.Current = new ServerRegistrarResolver(
|
||||
new ConfigServerRegistrar());
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
//using System;
|
||||
using System;
|
||||
|
||||
//namespace Umbraco.Core.Profiling
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Defines an object for use in the application to profile operations
|
||||
// /// </summary>
|
||||
// public interface IProfiler
|
||||
// {
|
||||
|
||||
// /// <summary>
|
||||
// /// Render the UI to display the profiler
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <remarks>
|
||||
// /// Generally used for HTML displays
|
||||
// /// </remarks>
|
||||
// string Render();
|
||||
namespace Umbraco.Core.Profiling
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an object for use in the application to profile operations
|
||||
/// </summary>
|
||||
internal interface IProfiler
|
||||
{
|
||||
|
||||
// /// <summary>
|
||||
// /// Profile a step
|
||||
// /// </summary>
|
||||
// /// <param name="name"></param>
|
||||
// /// <returns></returns>
|
||||
// /// <remarks>
|
||||
// /// Use the 'using(' syntax
|
||||
// /// </remarks>
|
||||
// IDisposable Step(string name);
|
||||
/// <summary>
|
||||
/// Render the UI to display the profiler
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Generally used for HTML displays
|
||||
/// </remarks>
|
||||
string Render();
|
||||
|
||||
// /// <summary>
|
||||
// /// Start the profiler
|
||||
// /// </summary>
|
||||
// void Start();
|
||||
/// <summary>
|
||||
/// Profile a step
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Use the 'using(' syntax
|
||||
/// </remarks>
|
||||
IDisposable Step(string name);
|
||||
|
||||
// /// <summary>
|
||||
// /// Start the profiler
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// set discardResults to false when you want to abandon all profiling, this is useful for
|
||||
// /// when someone is not authenticated or you want to clear the results based on some other mechanism.
|
||||
// /// </remarks>
|
||||
// void Stop(bool discardResults = false);
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// Start the profiler
|
||||
/// </summary>
|
||||
void Start();
|
||||
|
||||
/// <summary>
|
||||
/// Start the profiler
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// set discardResults to false when you want to abandon all profiling, this is useful for
|
||||
/// when someone is not authenticated or you want to clear the results based on some other mechanism.
|
||||
/// </remarks>
|
||||
void Stop(bool discardResults = false);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Umbraco.Core.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
//namespace Umbraco.Core.Profiling
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// A profiler that outputs its results to the LogHelper
|
||||
// /// </summary>
|
||||
// public class LogProfiler : IProfiler
|
||||
// {
|
||||
// public string Render()
|
||||
// {
|
||||
// return string.Empty;
|
||||
// }
|
||||
namespace Umbraco.Core.Profiling
|
||||
{
|
||||
/// <summary>
|
||||
/// A profiler that outputs its results to the LogHelper
|
||||
/// </summary>
|
||||
internal class LogProfiler : IProfiler
|
||||
{
|
||||
public string Render()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// public IDisposable Step(string name)
|
||||
// {
|
||||
// LogHelper.Debug(typeof(LogProfiler), "Starting - " + name);
|
||||
// return DisposableTimer.Start(l => LogHelper.Info(typeof (LogProfiler), () => name + " (took " + l + "ms)"));
|
||||
// }
|
||||
public IDisposable Step(string name)
|
||||
{
|
||||
LogHelper.Debug(typeof(LogProfiler), "Starting - " + name);
|
||||
return DisposableTimer.Start(l => LogHelper.Info(typeof(LogProfiler), () => name + " (took " + l + "ms)"));
|
||||
}
|
||||
|
||||
// public void Start()
|
||||
// {
|
||||
// //the log will alwasy be started
|
||||
// }
|
||||
public void Start()
|
||||
{
|
||||
//the log will alwasy be started
|
||||
}
|
||||
|
||||
// public void Stop(bool discardResults = false)
|
||||
// {
|
||||
// //we don't need to do anything here
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public void Stop(bool discardResults = false)
|
||||
{
|
||||
//we don't need to do anything here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using StackExchange.Profiling;
|
||||
|
||||
namespace Umbraco.Core.Profiling
|
||||
{
|
||||
public static class MiniProfilerExtensions
|
||||
internal static class ProfilerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes out a step prefixed with the type
|
||||
@@ -12,9 +11,9 @@ namespace Umbraco.Core.Profiling
|
||||
/// <param name="profiler"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static IDisposable Step<T>(this MiniProfiler profiler, string name)
|
||||
internal static IDisposable Step<T>(this IProfiler profiler, string name)
|
||||
{
|
||||
return profiler.Step(string.Format("[" + typeof (T).Name + "] " + name));
|
||||
return profiler.Step(string.Format(typeof(T).Name + ", " + name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
//using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
|
||||
//namespace Umbraco.Core.Profiling
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// A resolver exposing the current profiler
|
||||
// /// </summary>
|
||||
// public class ProfilerResolver : SingleObjectResolverBase<ProfilerResolver, IProfiler>
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Constructor
|
||||
// /// </summary>
|
||||
// /// <param name="profiler"></param>
|
||||
// public ProfilerResolver(IProfiler profiler)
|
||||
// : base(profiler)
|
||||
// {
|
||||
|
||||
// }
|
||||
namespace Umbraco.Core.Profiling
|
||||
{
|
||||
/// <summary>
|
||||
/// A resolver exposing the current profiler
|
||||
/// </summary>
|
||||
internal class ProfilerResolver : SingleObjectResolverBase<ProfilerResolver, IProfiler>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="profiler"></param>
|
||||
public ProfilerResolver(IProfiler profiler)
|
||||
: base(profiler)
|
||||
{
|
||||
|
||||
// /// <summary>
|
||||
// /// Method allowing to change the profiler during startup
|
||||
// /// </summary>
|
||||
// /// <param name="profiler"></param>
|
||||
// internal void SetProfiler(IProfiler profiler)
|
||||
// {
|
||||
// Value = profiler;
|
||||
// }
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets the current profiler
|
||||
// /// </summary>
|
||||
// public IProfiler Profiler
|
||||
// {
|
||||
// get { return Value; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// Method allowing to change the profiler during startup
|
||||
/// </summary>
|
||||
/// <param name="profiler"></param>
|
||||
internal void SetProfiler(IProfiler profiler)
|
||||
{
|
||||
Value = profiler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current profiler
|
||||
/// </summary>
|
||||
public IProfiler Profiler
|
||||
{
|
||||
get { return Value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,161 +1,161 @@
|
||||
//using System;
|
||||
//using System.Web;
|
||||
//using StackExchange.Profiling;
|
||||
//using Umbraco.Core.Configuration;
|
||||
//using Umbraco.Core.Logging;
|
||||
using System;
|
||||
using System.Web;
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
//namespace Umbraco.Core.Profiling
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// A profiler used for web based activity based on the MiniProfiler framework
|
||||
// /// </summary>
|
||||
// public class WebProfiler : IProfiler
|
||||
// {
|
||||
namespace Umbraco.Core.Profiling
|
||||
{
|
||||
/// <summary>
|
||||
/// A profiler used for web based activity based on the MiniProfiler framework
|
||||
/// </summary>
|
||||
internal class WebProfiler : IProfiler
|
||||
{
|
||||
|
||||
// /// <summary>
|
||||
// /// Constructor
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// Binds to application events to enable the MiniProfiler
|
||||
// /// </remarks>
|
||||
// internal WebProfiler()
|
||||
// {
|
||||
// UmbracoApplicationBase.ApplicationInit += UmbracoApplicationApplicationInit;
|
||||
// }
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Binds to application events to enable the MiniProfiler
|
||||
/// </remarks>
|
||||
internal WebProfiler()
|
||||
{
|
||||
UmbracoApplicationBase.ApplicationInit += UmbracoApplicationApplicationInit;
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Handle the Init event o fthe UmbracoApplication which allows us to subscribe to the HttpApplication events
|
||||
// /// </summary>
|
||||
// /// <param name="sender"></param>
|
||||
// /// <param name="e"></param>
|
||||
// void UmbracoApplicationApplicationInit(object sender, EventArgs e)
|
||||
// {
|
||||
// var app = sender as HttpApplication;
|
||||
// if (app == null) return;
|
||||
/// <summary>
|
||||
/// Handle the Init event o fthe UmbracoApplication which allows us to subscribe to the HttpApplication events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void UmbracoApplicationApplicationInit(object sender, EventArgs e)
|
||||
{
|
||||
var app = sender as HttpApplication;
|
||||
if (app == null) return;
|
||||
|
||||
// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
|
||||
// {
|
||||
// //If we don't have a high enough trust level we cannot bind to the events
|
||||
// LogHelper.Info<WebProfiler>("Cannot start the WebProfiler since the application is running in Medium trust");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// app.BeginRequest += UmbracoApplicationBeginRequest;
|
||||
// app.EndRequest += UmbracoApplicationEndRequest;
|
||||
// }
|
||||
// }
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
|
||||
{
|
||||
//If we don't have a high enough trust level we cannot bind to the events
|
||||
LogHelper.Info<WebProfiler>("Cannot start the WebProfiler since the application is running in Medium trust");
|
||||
}
|
||||
else
|
||||
{
|
||||
app.BeginRequest += UmbracoApplicationBeginRequest;
|
||||
app.EndRequest += UmbracoApplicationEndRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Handle the begin request event
|
||||
// /// </summary>
|
||||
// /// <param name="sender"></param>
|
||||
// /// <param name="e"></param>
|
||||
// void UmbracoApplicationEndRequest(object sender, EventArgs e)
|
||||
// {
|
||||
// if (GlobalSettings.DebugMode == false) return;
|
||||
// var request = TryGetRequest(sender);
|
||||
// if (request.Success == false) return;
|
||||
// if (request.Result.Url.IsClientSideRequest()) return;
|
||||
// if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
// {
|
||||
// //stop the profiler
|
||||
// Stop();
|
||||
// }
|
||||
// }
|
||||
/// <summary>
|
||||
/// Handle the begin request event
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void UmbracoApplicationEndRequest(object sender, EventArgs e)
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
var request = TryGetRequest(sender);
|
||||
if (request.Success == false) return;
|
||||
if (request.Result.Url.IsClientSideRequest()) return;
|
||||
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
{
|
||||
//stop the profiler
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Handle the end request event
|
||||
// /// </summary>
|
||||
// /// <param name="sender"></param>
|
||||
// /// <param name="e"></param>
|
||||
// void UmbracoApplicationBeginRequest(object sender, EventArgs e)
|
||||
// {
|
||||
// if (GlobalSettings.DebugMode == false) return;
|
||||
// var request = TryGetRequest(sender);
|
||||
// if (request.Success == false) return;
|
||||
// if (request.Result.Url.IsClientSideRequest()) return;
|
||||
// if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
// {
|
||||
// //start the profiler
|
||||
// Start();
|
||||
// }
|
||||
// }
|
||||
/// <summary>
|
||||
/// Handle the end request event
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void UmbracoApplicationBeginRequest(object sender, EventArgs e)
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
var request = TryGetRequest(sender);
|
||||
if (request.Success == false) return;
|
||||
if (request.Result.Url.IsClientSideRequest()) return;
|
||||
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
{
|
||||
//start the profiler
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Render the UI to display the profiler
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <remarks>
|
||||
// /// Generally used for HTML displays
|
||||
// /// </remarks>
|
||||
// public string Render()
|
||||
// {
|
||||
// return MiniProfiler.RenderIncludes().ToString();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Render the UI to display the profiler
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Generally used for HTML displays
|
||||
/// </remarks>
|
||||
public string Render()
|
||||
{
|
||||
return MiniProfiler.RenderIncludes().ToString();
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Profile a step
|
||||
// /// </summary>
|
||||
// /// <param name="name"></param>
|
||||
// /// <returns></returns>
|
||||
// /// <remarks>
|
||||
// /// Use the 'using(' syntax
|
||||
// /// </remarks>
|
||||
// public IDisposable Step(string name)
|
||||
// {
|
||||
// if (GlobalSettings.DebugMode == false) return null;
|
||||
/// <summary>
|
||||
/// Profile a step
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Use the 'using(' syntax
|
||||
/// </remarks>
|
||||
public IDisposable Step(string name)
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return null;
|
||||
|
||||
// return MiniProfiler.Current.Step(name);
|
||||
// }
|
||||
return MiniProfiler.Current.Step(name);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Start the profiler
|
||||
// /// </summary>
|
||||
// public void Start()
|
||||
// {
|
||||
// if (GlobalSettings.DebugMode == false) return;
|
||||
// //will not run in medium trust
|
||||
// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
/// <summary>
|
||||
/// Start the profiler
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
//will not run in medium trust
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
|
||||
// MiniProfiler.Start();
|
||||
// }
|
||||
MiniProfiler.Start();
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Start the profiler
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// set discardResults to false when you want to abandon all profiling, this is useful for
|
||||
// /// when someone is not authenticated or you want to clear the results based on some other mechanism.
|
||||
// /// </remarks>
|
||||
// public void Stop(bool discardResults = false)
|
||||
// {
|
||||
// if (GlobalSettings.DebugMode == false) return;
|
||||
// //will not run in medium trust
|
||||
// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
/// <summary>
|
||||
/// Start the profiler
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// set discardResults to false when you want to abandon all profiling, this is useful for
|
||||
/// when someone is not authenticated or you want to clear the results based on some other mechanism.
|
||||
/// </remarks>
|
||||
public void Stop(bool discardResults = false)
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
//will not run in medium trust
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
|
||||
// MiniProfiler.Stop(discardResults);
|
||||
// }
|
||||
MiniProfiler.Stop(discardResults);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets the request object from the app instance if it is available
|
||||
// /// </summary>
|
||||
// /// <param name="sender">The application object</param>
|
||||
// /// <returns></returns>
|
||||
// private Attempt<HttpRequestBase> TryGetRequest(object sender)
|
||||
// {
|
||||
// var app = sender as HttpApplication;
|
||||
// if (app == null) return Attempt<HttpRequestBase>.False;
|
||||
/// <summary>
|
||||
/// Gets the request object from the app instance if it is available
|
||||
/// </summary>
|
||||
/// <param name="sender">The application object</param>
|
||||
/// <returns></returns>
|
||||
private Attempt<HttpRequestBase> TryGetRequest(object sender)
|
||||
{
|
||||
var app = sender as HttpApplication;
|
||||
if (app == null) return Attempt<HttpRequestBase>.False;
|
||||
|
||||
// try
|
||||
// {
|
||||
// var req = app.Request;
|
||||
// return new Attempt<HttpRequestBase>(true, new HttpRequestWrapper(req));
|
||||
// }
|
||||
// catch (HttpException ex)
|
||||
// {
|
||||
// return new Attempt<HttpRequestBase>(ex);
|
||||
// }
|
||||
// }
|
||||
try
|
||||
{
|
||||
var req = app.Request;
|
||||
return new Attempt<HttpRequestBase>(true, new HttpRequestWrapper(req));
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
return new Attempt<HttpRequestBase>(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -525,7 +525,7 @@
|
||||
<Compile Include="Persistence\UnitOfWork\PetaPocoUnitOfWorkProvider.cs" />
|
||||
<Compile Include="Profiling\IProfiler.cs" />
|
||||
<Compile Include="Profiling\LogProfiler.cs" />
|
||||
<Compile Include="Profiling\MiniProfilerExtensions.cs" />
|
||||
<Compile Include="Profiling\ProfilerExtensions.cs" />
|
||||
<Compile Include="Profiling\ProfilerResolver.cs" />
|
||||
<Compile Include="Profiling\WebProfiler.cs" />
|
||||
<Compile Include="PropertyEditors\Attributes\PropertyEditorAttribute.cs" />
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace Umbraco.Core
|
||||
public static event EventHandler ApplicationStarting;
|
||||
public static event EventHandler ApplicationStarted;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the HttpApplication.Init() is fired, allows developers to subscribe to the HttpApplication events
|
||||
/// </summary>
|
||||
public static event EventHandler ApplicationInit;
|
||||
|
||||
/// <summary>
|
||||
/// Boots up the Umbraco application
|
||||
/// </summary>
|
||||
@@ -48,49 +53,17 @@ namespace Umbraco.Core
|
||||
protected void Application_Start(object sender, EventArgs e)
|
||||
{
|
||||
StartApplication(sender, e);
|
||||
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
|
||||
{
|
||||
//If we don't have a high enough trust level we cannot bind to the events
|
||||
LogHelper.Info<UmbracoApplicationBase>("Cannot use the MiniProfiler since the application is running in Medium trust");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the mini profiler for the request
|
||||
/// Override init and raise the event
|
||||
/// </summary>
|
||||
protected void Application_BeginRequest()
|
||||
public override void Init()
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
var request = TryGetRequest();
|
||||
if (request.Success == false) return;
|
||||
if (request.Result.Url.IsClientSideRequest()) return;
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
{
|
||||
//start the profiler
|
||||
MiniProfiler.Start();
|
||||
}
|
||||
base.Init();
|
||||
OnApplicationInit(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the mini profiler for the request
|
||||
/// </summary>
|
||||
protected void Application_EndRequest()
|
||||
{
|
||||
if (GlobalSettings.DebugMode == false) return;
|
||||
var request = TryGetRequest();
|
||||
if (request.Success == false) return;
|
||||
if (request.Result.Url.IsClientSideRequest()) return;
|
||||
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
|
||||
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
|
||||
{
|
||||
//stop the profiler
|
||||
MiniProfiler.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Developers can override this method to modify objects on startup
|
||||
/// </summary>
|
||||
@@ -112,7 +85,18 @@ namespace Umbraco.Core
|
||||
if (ApplicationStarted != null)
|
||||
ApplicationStarted(sender, e);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called to raise the ApplicationInit event
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnApplicationInit(object sender, EventArgs e)
|
||||
{
|
||||
if (ApplicationInit != null)
|
||||
ApplicationInit(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method that can be overridden to invoke code when the application has an error.
|
||||
/// </summary>
|
||||
@@ -162,22 +146,5 @@ namespace Umbraco.Core
|
||||
|
||||
protected abstract IBootManager GetBootManager();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request object from the app instance if it is available
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Attempt<HttpRequestBase> TryGetRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var req = Request;
|
||||
return new Attempt<HttpRequestBase>(true, new HttpRequestWrapper(req));
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
return new Attempt<HttpRequestBase>(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<%@ Register Src="controls/Tree/TreeControl.ascx" TagName="TreeControl" TagPrefix="umbraco" %>
|
||||
<%@ Import Namespace="StackExchange.Profiling" %>
|
||||
<%@ Import Namespace="Umbraco.Core.Profiling" %>
|
||||
<%@ Import Namespace="Umbraco.Web" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
|
||||
<%@ Register TagPrefix="uc1" TagName="quickSearch" Src="Search/QuickSearch.ascx" %>
|
||||
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
|
||||
@@ -392,7 +393,7 @@
|
||||
</script>
|
||||
<%if(string.IsNullOrEmpty(Request["umbDebug"]) == false && umbraco.GlobalSettings.DebugMode)
|
||||
{
|
||||
Response.Write(MiniProfiler.RenderIncludes());
|
||||
Response.Write(Html.RenderProfiler());
|
||||
}%>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -10,17 +10,29 @@ using System.Web.Routing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Dynamics;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Web.Mvc;
|
||||
using umbraco;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
/// <summary>
|
||||
/// HtmlHelper extensions for use in templates
|
||||
/// </summary>
|
||||
public static class HtmlHelperRenderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders the markup for the profiler
|
||||
/// </summary>
|
||||
/// <param name="helper"></param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderProfiler(this HtmlHelper helper)
|
||||
{
|
||||
return new HtmlString(ProfilerResolver.Current.Profiler.Render());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a partial view that is found in the specified area
|
||||
/// </summary>
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Web.Mvc
|
||||
}
|
||||
else
|
||||
{
|
||||
var profilerMarkup = MiniProfiler.RenderIncludes();
|
||||
var profilerMarkup = this.Html.RenderProfiler();
|
||||
text = text.Substring(0, pos) + profilerMarkup + text.Substring(pos, text.Length - pos);
|
||||
}
|
||||
base.WriteLiteral(text);
|
||||
|
||||
@@ -54,6 +54,18 @@ namespace Umbraco.Web.UI.Pages
|
||||
get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); }
|
||||
}
|
||||
|
||||
private HtmlHelper _html;
|
||||
/// <summary>
|
||||
/// Returns a HtmlHelper
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This html helper is created with an empty context and page so it may not have all of the functionality expected.
|
||||
/// </remarks>
|
||||
public HtmlHelper Html
|
||||
{
|
||||
get { return _html ?? (_html = new HtmlHelper(new ViewContext(), new ViewPage())); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current ApplicationContext
|
||||
/// </summary>
|
||||
|
||||
@@ -240,6 +240,9 @@ namespace Umbraco.Web
|
||||
{
|
||||
base.InitializeResolvers();
|
||||
|
||||
//Set the profiler to be the web profiler
|
||||
ProfilerResolver.Current.SetProfiler(new WebProfiler());
|
||||
|
||||
//set the default RenderMvcController
|
||||
DefaultRenderMvcControllerResolver.Current = new DefaultRenderMvcControllerResolver(typeof(RenderMvcController));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace umbraco
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
base.OnPreInit(e);
|
||||
using (MiniProfiler.Current.Step<UmbracoDefault>("PreInit"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<UmbracoDefault>("PreInit"))
|
||||
{
|
||||
|
||||
// handle the infamous umbDebugShowTrace, etc
|
||||
@@ -83,7 +83,7 @@ namespace umbraco
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<UmbracoDefault>("Init"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<UmbracoDefault>("Init"))
|
||||
{
|
||||
|
||||
base.OnInit(e);
|
||||
@@ -120,7 +120,7 @@ namespace umbraco
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<UmbracoDefault>("Load"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<UmbracoDefault>("Load"))
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace umbraco
|
||||
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<UmbracoDefault>("Render"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<UmbracoDefault>("Render"))
|
||||
{
|
||||
|
||||
// do the original rendering
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace umbraco
|
||||
/// <returns></returns>
|
||||
private string GetRecursiveValueLegacy(IDictionary elements)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<item>("Checking recusively"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<item>("Checking recusively"))
|
||||
{
|
||||
var content = "";
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace umbraco
|
||||
|
||||
private void ParseItem(IDictionary attributes)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<item>("Start parsing " + _fieldName))
|
||||
using (ProfilerResolver.Current.Profiler.Step<item>("Start parsing " + _fieldName))
|
||||
{
|
||||
HttpContext.Current.Trace.Write("item", "Start parsing '" + _fieldName + "'");
|
||||
if (helper.FindAttribute(attributes, "textIfEmpty") != "" && _fieldContent == "")
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace umbraco
|
||||
? string.Format("Render Inline Macro, Cache: {0})", Model.CacheDuration)
|
||||
: string.Format("Render Macro: {0}, type: {1}, cache: {2})", Name, Model.MacroType, Model.CacheDuration);
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>(macroInfo))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>(macroInfo))
|
||||
{
|
||||
TraceInfo("renderMacro", macroInfo);
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace umbraco
|
||||
return GetControlForErrorBehavior("Error loading Partial View script (file: " + ScriptFile + ")", macroErrorEventArgs);
|
||||
};
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Executing Partial View: " + Model.TypeName))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Executing Partial View: " + Model.TypeName))
|
||||
{
|
||||
TraceInfo("umbracoMacro", "Partial View added (" + Model.TypeName + ")");
|
||||
try
|
||||
@@ -318,7 +318,7 @@ namespace umbraco
|
||||
}
|
||||
case (int) MacroTypes.UserControl:
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Executing UserControl: " + Model.TypeName))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Executing UserControl: " + Model.TypeName))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -362,7 +362,7 @@ namespace umbraco
|
||||
|
||||
case (int) MacroTypes.CustomControl:
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Executing CustomControl: " + Model.TypeName + "." + Model.TypeAssembly))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Executing CustomControl: " + Model.TypeName + "." + Model.TypeAssembly))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -424,7 +424,7 @@ namespace umbraco
|
||||
return GetControlForErrorBehavior("Error loading MacroEngine script (file: " + ScriptFile + ")", macroErrorEventArgs);
|
||||
};
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Executing MacroEngineScript: " + ScriptFile))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Executing MacroEngineScript: " + ScriptFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -501,7 +501,7 @@ namespace umbraco
|
||||
{
|
||||
string dateAddedCacheKey;
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Saving MacroContent To Cache: " + Model.CacheIdentifier))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Saving MacroContent To Cache: " + Model.CacheIdentifier))
|
||||
{
|
||||
|
||||
// NH: Scripts and XSLT can be generated as strings, but not controls as page events wouldn't be hit (such as Page_Load, etc)
|
||||
@@ -831,7 +831,7 @@ namespace umbraco
|
||||
return new LiteralControl(string.Empty);
|
||||
}
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Executing XSLT: " + XsltFile))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Executing XSLT: " + XsltFile))
|
||||
{
|
||||
XmlDocument macroXml = null;
|
||||
|
||||
@@ -860,7 +860,7 @@ namespace umbraco
|
||||
{
|
||||
var xsltFile = getXslt(XsltFile);
|
||||
|
||||
using (MiniProfiler.Current.Step<macro>("Performing transformation"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<macro>("Performing transformation"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.UI;
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Web;
|
||||
using umbraco.presentation.LiveEditing;
|
||||
using umbraco.presentation.LiveEditing.Controls;
|
||||
using System.IO;
|
||||
@@ -41,7 +43,8 @@ namespace umbraco.presentation.masterpages
|
||||
base.Render(new HtmlTextWriter(baseWriter));
|
||||
var baseOutput = baseWriter.ToString();
|
||||
|
||||
baseOutput = baseOutput.Replace("</body>", MiniProfiler.RenderIncludes() + "</body>");
|
||||
var htmlHelper = new HtmlHelper(new ViewContext(), new ViewPage());
|
||||
baseOutput = baseOutput.Replace("</body>", htmlHelper.RenderProfiler() + "</body>");
|
||||
writer.Write(baseOutput);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
@@ -9,6 +10,7 @@ using System.Web.UI.WebControls;
|
||||
//which would result in an error. so we have kept the old namespaces intact with references to new ones
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Web;
|
||||
using mp = umbraco.presentation.masterpages;
|
||||
namespace umbraco.presentation.umbraco.masterpages
|
||||
{
|
||||
@@ -43,10 +45,10 @@ namespace umbraco.presentation.masterpages
|
||||
// profiling
|
||||
if (string.IsNullOrEmpty(Request.QueryString["umbDebug"]) == false && GlobalSettings.DebugMode)
|
||||
{
|
||||
baseOutput = baseOutput.Replace("</body>", MiniProfiler.RenderIncludes() + "</body>");
|
||||
var htmlHelper = new HtmlHelper(new ViewContext(), new ViewPage());
|
||||
baseOutput = baseOutput.Replace("</body>", htmlHelper.RenderProfiler() + "</body>");
|
||||
}
|
||||
|
||||
|
||||
// write modified output
|
||||
writer.Write(baseOutput);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace umbraco.presentation.templateControls
|
||||
/// <param name="item">The item.</param>
|
||||
public virtual void Load(Item item)
|
||||
{
|
||||
using (MiniProfiler.Current.Step<ItemRenderer>(string.Format("Item: {0}", item.Field)))
|
||||
using (ProfilerResolver.Current.Profiler.Step<ItemRenderer>(string.Format("Item: {0}", item.Field)))
|
||||
{
|
||||
ParseMacros(item);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace umbraco.presentation.templateControls
|
||||
|
||||
string elementText = GetFieldContents(item);
|
||||
|
||||
using (MiniProfiler.Current.Step<ItemRenderer>("Parsing Macros"))
|
||||
using (ProfilerResolver.Current.Profiler.Step<ItemRenderer>("Parsing Macros"))
|
||||
{
|
||||
|
||||
MacroTagParser.ParseMacros(
|
||||
|
||||
Reference in New Issue
Block a user