pr1/presence/Presence.Desktop/App.axaml.cs

47 lines
1.2 KiB
C#
Raw Normal View History

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