Files
GreadyPoang/GreadyPoang/MauiProgram.cs
2025-10-12 14:34:54 +02:00

64 lines
2.3 KiB
C#

using Common.Library;
using GreadyPoang.CommandClasses;
using GreadyPoang.DataLayer;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using GreadyPoang.Views;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace GreadyPoang;
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");
});
builder.Services.AddDbContext<DataContext>(options =>
{
var MauiDataPath = FileSystem.Current.AppDataDirectory;
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
{
File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
}
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
options.UseSqlite($"Data Source={dbPath}");
});
builder.Services.AddScoped<IRepository<Participant>, ParticipantRepository>();
builder.Services.AddScoped<ParticipantViewModelCommands>();
builder.Services.AddScoped<ParticipantListView>();
builder.Services.AddScoped<IRepository<GameRound>, GameRoundRepository>();
builder.Services.AddScoped<RoundStartingViewModelCommands>();
builder.Services.AddScoped<RoundStartingView>();
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
builder.Services.AddScoped<RoundRunningViewModelCommands>();
builder.Services.AddScoped<RoundRunningView>();
builder.Services.AddScoped<IMethodSharingService<Participant>, MethodSharingService>();
builder.Services.AddScoped<ICombinedRepository, CombinedRepository>();
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}