48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using DIDemoLib;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using WinFormDiApp.DAL;
|
|
using WinFormDiApp.DAL.Data;
|
|
|
|
namespace WinFormDiApp
|
|
{
|
|
internal static class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
var host = ContainerConfig.Configure(CreateHostBuilder(args));
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
try
|
|
{
|
|
var services = scope.ServiceProvider;
|
|
|
|
var context = services.GetRequiredService<ApplicationDbContext>();
|
|
DataSeeder.Initialize(context);
|
|
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
|
|
|
var frm = services.GetRequiredService<MainWindow>();
|
|
Application.Run(frm);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"An error has occured: {ex.Message}");
|
|
}
|
|
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args);
|
|
|
|
|
|
|
|
}
|
|
} |