private static IDbProfiler GetDbProfiler(IProfiler profiler) { if (profiler is IDbProfiler dbProfiler) { return(dbProfiler); } return(profiler.GetMiniProfiler()); }
/// <summary> /// Returns an <see cref="IDisposable"/> that will time the code between its creation and disposal. /// </summary> /// <param name="profiler">The current profiling session or null.</param> /// <param name="name">A descriptive name for the code that is encapsulated by the resulting IDisposable's lifetime.</param> /// <param name="level">This step's visibility level; allows filtering when <see cref="MiniProfiler.Start"/> is called.</param> public static IDisposable Step(this IProfiler profiler, string name, ProfileLevel level) { var miniProfiler = profiler.GetMiniProfiler(); if (CustomStepFn != null) { return(CustomStepFn(miniProfiler, name)); } return(profiler == null ? null : miniProfiler.StepImpl(name, level)); }