presence/Presence.Desktop/App.axaml.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2024-11-24 18:05:17 +00:00
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Microsoft.Extensions.DependencyInjection;
using Presence.Desktop.DI;
using Presence.Desktop.ViewModels;
using Presence.Desktop.Views;
2024-12-16 04:10:04 +00:00
using domain.UseCase;
2024-11-24 18:05:17 +00:00
namespace Presence.Desktop
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddCommonService();
2024-12-16 04:10:04 +00:00
serviceCollection.AddSingleton<GroupUseCase>();
2024-11-24 18:05:17 +00:00
var services = serviceCollection.BuildServiceProvider();
var mainViewModel = services.GetRequiredService<MainWindowViewModel>();
2024-12-16 04:10:04 +00:00
var groupUseCase = services.GetRequiredService<GroupUseCase>();
2024-11-24 18:05:17 +00:00
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
2024-12-16 04:10:04 +00:00
desktop.MainWindow = new MainWindow(groupUseCase)
2024-11-24 18:05:17 +00:00
{
DataContext = mainViewModel,
};
}
base.OnFrameworkInitializationCompleted();
}
}
2024-12-16 04:10:04 +00:00
}