-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
72 lines (63 loc) · 2.43 KB
/
MauiProgram.cs
File metadata and controls
72 lines (63 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using CommunityToolkit.Maui;
using EShop;
using EShopNative.BaseLibrary;
using EShopNative.Interfaces;
using EShopNative.Pages;
using EShopNative.Services;
using EShopNative.ViewModels;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
namespace EShopNative
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("MaterialIcons-Regular.ttf", "MaterialIcon");
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
// -----------------------------
// CORRECT HttpClient registration
// -----------------------------
builder.Services.AddHttpClient<AuthService>(client =>
{
client.BaseAddress = new Uri(AppConstants.BaseApiUrl);
});
// -----------------------------
// Register Services
// -----------------------------
builder.Services.AddSingleton<ISessionManager, SessionManager>();
builder.Services.AddSingleton<IAlertService, AlertService>();
builder.Services.AddSingleton<INavigationService, NavigationService>();
builder.Services.AddSingleton<IdleTimeoutService>();
// -----------------------------
// Register ViewModels
// -----------------------------
builder.Services.AddTransient<UserRoleEntryViewModel>();
builder.Services.AddTransient<HomePageViewModel>();
// -----------------------------
// Register Pages
// -----------------------------
builder.Services.AddTransient<UserRoleEntry>();
builder.Services.AddTransient<HomePage>();
builder.Services.AddTransient<RegisterPage>();
// -----------------------------
// Register App
// -----------------------------
builder.Services.AddSingleton<App>();
#if DEBUG
builder.Logging.AddDebug();
builder.Logging.AddConsole();
#endif
return builder.Build();
}
}
}