autosos-maui/MauiProgram.cs

52 lines
1.4 KiB
C#
Raw Permalink Normal View History

2023-12-29 14:10:37 +08:00
using autosos_maui.ViewModels;
using autosos_maui.Views;
using CommunityToolkit.Maui;
2023-12-28 17:29:36 +08:00
using Microsoft.Extensions.Logging;
namespace autosos_maui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
2023-12-29 14:10:37 +08:00
})
.RegisterViews()
.RegisterViewModels()
.RegisterAppServices();
2023-12-28 17:29:36 +08:00
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
2023-12-29 14:10:37 +08:00
public static MauiAppBuilder RegisterViews(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddTransient<LoginView>();
2023-12-29 17:37:14 +08:00
mauiAppBuilder.Services.AddTransient<HomeView>();
2023-12-29 14:10:37 +08:00
return mauiAppBuilder;
}
public static MauiAppBuilder RegisterViewModels(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddSingleton<LoginViewModel>();
2023-12-29 17:37:14 +08:00
mauiAppBuilder.Services.AddSingleton<HomeViewModel>();
2023-12-29 14:10:37 +08:00
return mauiAppBuilder;
}
public static MauiAppBuilder RegisterAppServices(this MauiAppBuilder mauiAppBuilder)
{
return mauiAppBuilder;
}
2023-12-28 17:29:36 +08:00
}