Files
Wino-Mail/Wino.Calendar/App.xaml.cs

91 lines
3.0 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
2024-04-18 01:44:37 +02:00
using Windows.ApplicationModel.Activation;
using Windows.UI.Core.Preview;
using Wino.Activation;
using Wino.Calendar.Activation;
using Wino.Calendar.Services;
using Wino.Calendar.ViewModels;
using Wino.Core;
using Wino.Core.Domain.Interfaces;
using Wino.Core.UWP;
2024-04-18 01:44:37 +02:00
namespace Wino.Calendar
{
public sealed partial class App : WinoApplication
2024-04-18 01:44:37 +02:00
{
public override string AppCenterKey => "dfdad6ab-95f9-44cc-9112-45ec6730c49e";
2024-04-18 01:44:37 +02:00
public App()
{
InitializeComponent();
2024-04-18 01:44:37 +02:00
}
public override IServiceProvider ConfigureServices()
2024-04-18 01:44:37 +02:00
{
var services = new ServiceCollection();
2024-04-18 01:44:37 +02:00
services.RegisterCoreServices();
services.RegisterCoreUWPServices();
services.RegisterCoreViewModels();
2024-04-18 01:44:37 +02:00
RegisterUWPServices(services);
RegisterViewModels(services);
RegisterActivationHandlers(services);
2024-04-18 01:44:37 +02:00
return services.BuildServiceProvider();
}
2024-04-18 01:44:37 +02:00
#region Dependency Injection
2024-04-18 01:44:37 +02:00
private void RegisterActivationHandlers(IServiceCollection services)
{
//services.AddTransient<ProtocolActivationHandler>();
//services.AddTransient<ToastNotificationActivationHandler>();
//services.AddTransient<FileActivationHandler>();
2024-04-18 01:44:37 +02:00
}
private void RegisterUWPServices(IServiceCollection services)
2024-04-18 01:44:37 +02:00
{
services.AddSingleton<INavigationService, NavigationService>();
services.AddSingleton<ICalendarDialogService, DialogService>();
services.AddTransient<ISettingsBuilderService, SettingsBuilderService>();
services.AddTransient<IProviderService, ProviderService>();
2024-04-18 01:44:37 +02:00
}
private void RegisterViewModels(IServiceCollection services)
{
services.AddSingleton(typeof(AppShellViewModel));
services.AddTransient(typeof(CalendarPageViewModel));
services.AddTransient(typeof(CalendarSettingsPageViewModel));
services.AddTransient(typeof(AccountManagementViewModel));
}
#endregion
protected override void OnApplicationCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
2024-04-18 01:44:37 +02:00
{
// TODO: Check server running.
2024-04-18 01:44:37 +02:00
}
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
LogActivation($"OnLaunched -> {args.GetType().Name}, Kind -> {args.Kind}, PreviousExecutionState -> {args.PreviousExecutionState}, IsPrelaunch -> {args.PrelaunchActivated}");
if (!args.PrelaunchActivated)
{
await ActivateWinoAsync(args);
}
}
protected override IEnumerable<ActivationHandler> GetActivationHandlers()
{
return null;
}
protected override ActivationHandler<IActivatedEventArgs> GetDefaultActivationHandler()
=> new DefaultActivationHandler();
2024-04-18 01:44:37 +02:00
}
}