using System;
namespace Umbraco.Cms.Core.Logging
{
internal static class ProfilerExtensions
{
///
/// Gets an that will time the code between its creation and disposal,
/// prefixing the name of the step with a reporting type name.
///
/// The reporting type.
/// The profiler.
/// The name of the step.
/// A step.
/// The returned is meant to be used within a using (...) {{ ... }} block.
internal static IDisposable Step(this IProfiler profiler, string name)
{
if (profiler == null) throw new ArgumentNullException(nameof(profiler));
return profiler.Step(typeof (T), name);
}
///
/// Gets an that will time the code between its creation and disposal,
/// prefixing the name of the step with a reporting type name.
///
/// The profiler.
/// The reporting type.
/// The name of the step.
/// A step.
/// The returned is meant to be used within a using (...) {{ ... }} block.
internal static IDisposable Step(this IProfiler profiler, Type reporting, string name)
{
if (profiler == null) throw new ArgumentNullException(nameof(profiler));
if (reporting == null) throw new ArgumentNullException(nameof(reporting));
if (name == null) throw new ArgumentNullException(nameof(name));
return profiler.Step($"[{reporting.Name}] {name}");
}
}
}