-
Notifications
You must be signed in to change notification settings - Fork 0
/
MauiProgram.cs
48 lines (43 loc) · 1.29 KB
/
MauiProgram.cs
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
using AppControleFinanceiro.Repositories;
using AppControleFinanceiro.Views;
using LiteDB;
using Microsoft.Extensions.Logging;
namespace AppControleFinanceiro;
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");
})
.RegisterDataBaseAndRepositories()
.RegisterViews();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
public static MauiAppBuilder RegisterDataBaseAndRepositories(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddSingleton<LiteDatabase>(
options =>
{
return new LiteDatabase($"Filename={AppSettings.DatabasePath};Connection=Shared");
}
);
mauiAppBuilder.Services.AddTransient<ITransactionRepository, TransactionRepository>();
return mauiAppBuilder;
}
public static MauiAppBuilder RegisterViews(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddTransient<TransactionAdd>();
mauiAppBuilder.Services.AddTransient<TransactionEdit>();
mauiAppBuilder.Services.AddTransient<TransactionList>();
return mauiAppBuilder;
}
}