using System; using System.Net.Http; using System.Threading.Tasks; using BlazorAdmin; using BlazorAdmin.Services; using Blazored.LocalStorage; using BlazorShared; using BlazorShared.Models; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#admin"); builder.RootComponents.Add("head::after"); var configSection = builder.Configuration.GetRequiredSection(BaseUrlConfiguration.CONFIG_NAME); builder.Services.Configure(configSection); builder.Services.AddScoped(sp => new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddAuthorizationCore(); builder.Services.AddScoped(); builder.Services.AddScoped(sp => (CustomAuthStateProvider)sp.GetRequiredService()); builder.Services.AddBlazorServices(); builder.Logging.AddConfiguration(builder.Configuration.GetRequiredSection("Logging")); await ClearLocalStorageCache(builder.Services); await builder.Build().RunAsync(); static async Task ClearLocalStorageCache(IServiceCollection services) { var sp = services.BuildServiceProvider(); var localStorageService = sp.GetRequiredService(); await localStorageService.RemoveItemAsync(typeof(CatalogBrand).Name); await localStorageService.RemoveItemAsync(typeof(CatalogType).Name); }