// Reset for each inheritor protected BaseTest() { // instance per class, so multiple tests swapping the provider don't cause issues here // it's not a threading issue of the profiler, but rather tests swapping providers _provider = new DefaultProfilerProvider(); ResetProviders(); }
/// <summary> /// Sets a provider as the <see cref="MiniProfilerBaseOptions.ProfilerProvider"/> and optionally as the provider for <see cref="MiniProfiler.Current"/>. /// Extension method to support chaining while retaining the derivative options type. /// </summary> /// <typeparam name="T">The subtype of <see cref="MiniProfilerBaseOptions"/> to use (inferred for common usage).</typeparam> /// <param name="options">The options to set the provider on.</param> /// <param name="provider">The provider to use.</param> /// <param name="setAsCurrentProvider">Whether it should be set as the provider for getting <see cref="MiniProfiler.Current"/>.</param> public static T SetProvider <T>(this T options, IAsyncProfilerProvider provider, bool setAsCurrentProvider = true) where T : MiniProfilerBaseOptions { options.ProfilerProvider = provider ?? throw new ArgumentException(nameof(provider)); if (setAsCurrentProvider) { MiniProfilerBaseOptions.CurrentProfilerProvider = provider; } return(options); }
public DotVVMProfilerProvider(IAsyncProfilerProvider provider) { this.provider = provider; }
/// <summary> /// Initializes a new instance of the <see cref="ProfiledDbConnection"/> class. /// Returns a new <see cref="ProfiledDbConnection"/> that wraps <paramref name="connection"/>, /// providing query execution profiling. If profiler is null, no profiling will occur. /// </summary> /// <param name="connection"><c>Your provider-specific flavour of connection, e.g. SqlConnection, OracleConnection</c></param> /// <param name="profiler">The currently started <see cref="MiniProfiler"/> or null.</param> /// <exception cref="ArgumentNullException">Throws when <paramref name="connection"/> is <c>null</c>.</exception> public ContextProfiledDbConnection(DbConnection connection, IAsyncProfilerProvider profilerProvider) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _connection.StateChange += StateChangeHandler; _profilerProvider = profilerProvider; }