示例#1
0
 private ValueTask <bool> InitializeChart(IJSRuntime jSRuntime, DotNetObjectReference <ChartAdapter> dotNetObjectReference, bool hasClickEvent, bool hasHoverEvent, string canvasId, ChartData <Point> data, LineChartOptions options, string dataJsonString, string optionsJsonString)
 {
     return(JSRuntimeExtensions.InvokeAsync <bool>(jSRuntime, "blazoriseCharts.initialize", new object[9]
     {
         dotNetObjectReference,
         hasClickEvent,
         hasHoverEvent,
         canvasId,
         "scatter",
         ToChartDataSet(data),
         options,
         dataJsonString,
         optionsJsonString
     }));
 }
 /// <summary>
 /// Invoke the specified method with JSInterop and returns default(T) if the timeout is reached
 /// </summary>
 /// <param name="jsRuntime">js runtime on which we'll execute the query</param>
 /// <param name="identifier">method identifier</param>
 /// <param name="timeout">timeout until e return default(T)</param>
 /// <param name="args">method arguments</param>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static async ValueTask <T> InvokeOrDefaultAsync <T>(this IJSRuntime jsRuntime, string identifier, TimeSpan timeout, params object[] args)
 {
     try
     {
         return(await JSRuntimeExtensions.InvokeAsync <T>(
                    jsRuntime : jsRuntime,
                    identifier : identifier,
                    timeout : timeout,
                    args : args));
     }
     catch (TaskCanceledException)
     {
         //when timeout is reached it raises an exception
         return(await Task.FromResult(default(T)));
     }
 }