private static void EnsureHttpClient(IServiceCollection aServiceCollection) { var blazorHostingLocation = new BlazorHostingLocation(); // Server Side Blazor doesn't register HttpClient by default if (blazorHostingLocation.IsServerSide) { // Double check that nothing is registered. if (!aServiceCollection.Any(aServiceDescriptor => aServiceDescriptor.ServiceType == typeof(HttpClient))) { // Setup HttpClient for server side in a client side compatible fashion aServiceCollection.AddScoped <HttpClient> ( aServiceProvider => { // Creating the NavigationManager needs to wait until the JS Runtime is initialized, so defer it. NavigationManager navigationManager = aServiceProvider.GetRequiredService <NavigationManager>(); return(new HttpClient { BaseAddress = new Uri(navigationManager.BaseUri) }); } ); } } }
public ReduxDevToolsInterop( ILogger <ReduxDevToolsInterop> aLogger, IReduxDevToolsStore aStore, BlazorHostingLocation aBlazorHostingLocation) { Logger = aLogger; Store = aStore; BlazorHostingLocation = aBlazorHostingLocation; }
public JsonRequestHandler( ILogger <JsonRequestHandler> aLogger, IMediator aMediator, BlazorHostingLocation aBlazorHostingLocation) { Logger = aLogger; Logger.LogDebug($"{GetType().Name}: constructor"); Mediator = aMediator; BlazorHostingLocation = aBlazorHostingLocation; }