Neighbourhood.omg.lol/MauiProgram.cs

50 lines
1.8 KiB
C#
Raw Permalink Normal View History

using Markdig;
using Microsoft.AspNetCore.Components.Authorization;
2024-06-05 12:41:08 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Neighbourhood.omg.lol.Models;
using System.Reflection;
2024-05-30 01:06:08 +00:00
namespace Neighbourhood.omg.lol {
public static class MauiProgram {
public static MauiApp CreateMauiApp() {
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts => {
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
builder.Services.AddMauiBlazorWebView();
builder.Services.AddTransient<LoginWebViewPage>();
2024-06-05 12:41:08 +00:00
builder.Services.AddTransient<EphemeralWebPage>();
builder.Services.AddSingleton<RestService>();
builder.Services.AddSingleton<State>();
builder.Services.AddSingleton<NavigatorService>();
//ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
//builder.Services.AddSingleton<IConfiguration>(configurationBuilder.AddUserSecrets<App>().Build());
var assembly = Assembly.GetExecutingAssembly();
var details = assembly.GetName();
App.Name = details.Name!;
App.Version = details.Version!.ToString();
var appSettings = $"{App.Name}.appsettings.json";
using var stream = assembly.GetManifestResourceStream(appSettings);
var config = new ConfigurationBuilder().AddJsonStream(stream).Build();
builder.Configuration.AddConfiguration(config);
2024-06-05 12:41:08 +00:00
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<CustomAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(s => s.GetRequiredService<CustomAuthenticationStateProvider>());
2024-05-30 01:06:08 +00:00
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
2024-05-30 01:06:08 +00:00
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}