Files
PiperFeladat/Feladat1/Program.cs
2025-09-27 23:01:24 +02:00

32 lines
973 B
C#

using Feladat1.UI.MainWindow;
using Logic;
using Microsoft.Extensions.DependencyInjection;
using Repository;
namespace Feladat1;
class Program
{
static int Main()
{
var serviceProvider = SetupServices();
var application = Adw.Application.New("org.piper.feladat1", Gio.ApplicationFlags.FlagsNone);
application.OnActivate += (sender, args) =>
{
var userService = serviceProvider.GetService<IUserService>();
var window = new MainWindow(userService).Window;
window.Application = (Adw.Application)sender;
window.Show();
};
return application.RunWithSynchronizationContext(null);
}
private static ServiceProvider SetupServices()
{
var services = new ServiceCollection();
services.AddSingleton<IRepository, JsonRepository>();
services.AddSingleton<IUserService, UserService>();
return services.BuildServiceProvider();
}
}