autosos-maui/MauiProgram.cs

51 lines
1.3 KiB
C#
Raw 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>();
return mauiAppBuilder;
}
public static MauiAppBuilder RegisterViewModels(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddSingleton<LoginViewModel>();
return mauiAppBuilder;
}
public static MauiAppBuilder RegisterAppServices(this MauiAppBuilder mauiAppBuilder)
{
return mauiAppBuilder;
}
2023-12-28 17:29:36 +08:00
}