using decePubClient; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using System.Net.Http.Headers; using System.Text.Json; using Append.Blazor.Notifications; using Blazored.LocalStorage; using Blazored.Modal; using decePubClient.Extensions; using decePubClient.Services; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; using Toolbelt.Blazor.Extensions.DependencyInjection; using Microsoft.AspNetCore.Components.Authorization; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); // builder.RootComponents.Add("head::after"); builder.Services.AddBlazorDownloadFile(); builder.Services.AddOptions() .AddTransient(); builder.Services.AddBlazoredLocalStorage(config => { config.JsonSerializerOptions.WriteIndented = false; config.JsonSerializerOptions.PropertyNameCaseInsensitive = true; config.JsonSerializerOptions.IgnoreReadOnlyProperties = true; config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip; config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; }) .AddBlazoredModal() //.AddScoped() .AddScoped() .AddScoped() //.AddScoped(provider => provider.GetRequiredService()) //.AddTransient() .AddHeadElementHelper(options => options.DisableClientScriptAutoInjection = true) .AddLocalization() .AddNotifications() .AddTransient() .AddIndexedDb(); builder.Services.AddOidcAuthentication(options => { builder.Configuration.Bind("Local", options.ProviderOptions); options.ProviderOptions.Authority = "https://demo.identityserver.io"; options.ProviderOptions.ClientId = "interactive.public"; options.ProviderOptions.ResponseType = "code"; options.ProviderOptions.DefaultScopes.Add("api"); options.ProviderOptions.DefaultScopes.Add("email"); options.ProviderOptions.DefaultScopes.Add("profile"); }); builder.Services.AddHttpClient("default", client => { client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }); builder.Services.AddHttpClient("ComponentsWebAssembly_CSharp.ServerAPI", client => { client.BaseAddress = new Uri("https://demo.identityserver.io"); }) //.AddHttpMessageHandler() .AddHttpMessageHandler(); builder.Services.AddTransient(sp => sp.GetRequiredService().CreateClient("ComponentsWebAssembly_CSharp.ServerAPI")); builder.Services.AddScoped(); var host = builder.Build(); await host.SetDefaultCulture(); await host.RunAsync();