protected override void OnPreRender(IDotvvmRequestContext context) { var authorized = false; #if OWIN var options = (StackExchange.Profiling.MiniProfiler.Current?.Options ?? StackExchange.Profiling.MiniProfiler.DefaultOptions) as MiniProfilerOptions; authorized = options?.ResultsAuthorize?.Invoke(HttpContext.Current.Request) ?? false; #else var options = (StackExchange.Profiling.MiniProfiler.Current?.Options ?? StackExchange.Profiling.MiniProfiler.DefaultOptions) as MiniProfilerOptions; if (options != null) { authorized = options.ResultsAuthorize?.Invoke(context.GetAspNetCoreContext().Request) ?? false; if (options.ResultsAuthorize == null && options.ResultsAuthorizeAsync is object) { // TODO: REVIEW whether this usage is correctly implemented authorized = Task.Run(async() => { return(await options.ResultsAuthorizeAsync(context.GetAspNetCoreContext().Request).ConfigureAwait(false)); }).GetAwaiter().GetResult(); } } #endif if (authorized) { var javascript = MiniProfilerJavascriptResourceManager.GetWigetInlineJavascriptContent(); context.ResourceManager.AddStartupScript("DotVVM-MiniProfiler-Integration", javascript, "dotvvm"); } base.OnPreRender(context); }
public void Widget_InlineJavascript() { var data = MiniProfilerJavascriptResourceManager.GetWigetInlineJavascriptContent(); Assert.NotEmpty(data); }