using Blazored.LocalStorage; using Lantean.QBitTorrentClient; using Lantean.QBTMud.Services; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor; using MudBlazor.Services; namespace Lantean.QBTMud { public static class Program { public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); builder.Services.AddMudServices(); Uri baseAddress; #if DEBUG #pragma warning disable S1075 // URIs should not be hardcoded - used for debugging only baseAddress = new Uri("http://localhost:8080"); #pragma warning restore S1075 // URIs should not be hardcoded #else baseAddress = new Uri(builder.HostEnvironment.BaseAddress); #endif builder.Services.AddTransient(); builder.Services.AddScoped(); builder.Services .AddScoped(sp => sp .GetRequiredService() .CreateClient("API")) .AddHttpClient("API", client => client.BaseAddress = new Uri(baseAddress, "/api/v2/")) .AddHttpMessageHandler() .RemoveAllLoggers() .AddLogger(wrapHandlersPipeline: true); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddSingleton(); builder.Services.AddTransient(); #if DEBUG builder.Logging.SetMinimumLevel(LogLevel.Information); #else builder.Logging.SetMinimumLevel(LogLevel.Error); #endif MudGlobal.InputDefaults.ShrinkLabel = true; await builder.Build().RunAsync(); } } }