-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (44 loc) · 1.87 KB
/
Program.cs
File metadata and controls
53 lines (44 loc) · 1.87 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
using Feedback_Flow.Models;
using Feedback_Flow.Services;
using Feedback_Flow.Services.Interfaces;
using Feedback_Flow.UI.Forms;
using Microsoft.Extensions.DependencyInjection;
namespace Feedback_Flow;
internal static class Program
{
public static IServiceProvider ServiceProvider { get; private set; }
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
ApplicationConfiguration.Initialize();
// Setup Dependency Injection
var services = new ServiceCollection();
ConfigureServices(services);
ServiceProvider = services.BuildServiceProvider();
// Run Database Migration
var databaseService = ServiceProvider.GetRequiredService<IDatabaseService>();
Task.Run(async () => await databaseService.InitializeDatabaseAsync()).Wait();
var migrationService = ServiceProvider.GetRequiredService<IMigrationService>();
Task.Run(async () => await migrationService.MigrateFromCsvAsync()).Wait();
// Resolve MainDashboard
var mainForm = ServiceProvider.GetRequiredService<MainDashboard>();
Application.Run(mainForm);
}
private static void ConfigureServices(IServiceCollection services)
{
// Services
services.AddSingleton<IDatabaseService, SqliteDatabaseService>();
services.AddSingleton<IMigrationService, MigrationService>();
services.AddSingleton<IFileSystemService, FileSystemService>();
services.AddSingleton<IPdfService, PdfGenerationService>();
services.AddSingleton<IEmailService, OutlookEmailService>();
services.AddSingleton<IStudentService, StudentService>();
services.AddSingleton<INoteService, NoteService>();
// Forms
services.AddTransient<MainDashboard>();
}
}