-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
38 lines (32 loc) · 1.18 KB
/
MauiProgram.cs
File metadata and controls
38 lines (32 loc) · 1.18 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
using DataSyncToDoClientApp.MAUI.Models;
using DataSyncToDoClientApp.MAUI.Services;
using DataSyncToDoClientApp.MAUI.ViewModels;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace DataSyncToDoClientApp.MAUI;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
var dbConnection = new SqliteConnection("Data Source=:memory:");
dbConnection.Open();
builder.Services.AddTransient<MainPage>()
.AddTransient<MainViewModel>()
.AddTransient<IAlertService, AlertService>()
.AddScoped<IDbInitializer, DbContextInitializer>()
.AddDbContext<AppDbContext>(options => options.UseSqlite(dbConnection));
return builder.Build();
}
}