public ReduxDevToolsInterop( ILogger <ReduxDevToolsInterop> aLogger, IReduxDevToolsStore aStore, JsRuntimeLocation aJsRuntimeLocation) { Logger = aLogger; Store = aStore; JsRuntimeLocation = aJsRuntimeLocation; }
private static void EnsureHttpClient(IServiceCollection aServices) { var jsRuntimeLocation = new JsRuntimeLocation(); // Server Side Blazor doesn't register HttpClient by default if (jsRuntimeLocation.IsServerSide) { // Double check that nothing is registered. if (!aServices.Any(aServiceDescriptor => aServiceDescriptor.ServiceType == typeof(HttpClient))) { // Setup HttpClient for server side in a client side compatible fashion aServices.AddScoped <HttpClient>(aServiceProvider => { // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it. IUriHelper uriHelper = aServiceProvider.GetRequiredService <IUriHelper>(); return(new HttpClient { BaseAddress = new Uri(uriHelper.GetBaseUri()) }); }); } } }