Files
Wino-Mail/Wino.Server/Core/ServerMessageHandlerFactory.cs
Aleh Khantsevich 2ec05ea7cc UWP .NET9 (#555)
* Ground work for NET9 UWP switch.

* Add launch settings for Wino.Mail

* Added new test WAP project

* fix platforms in slnx solution

* ManagePackageVersionsCentrally set default

* Fixing assets and couple issues with the new packaging project.

* Add back markdown

* Fix nuget warnings

* FIx error in WAP about build tools

* Add build.props with default language preview

* Some AOT compilation progress.

* More AOT stuff.

* Remove deprecated protocol auth activation handler.

* Fix remaining protocol handler for google auth.

* Even more AOT

* More more AOT fixes

* Fix a few more AOT warnings

* Fix signature editor AOT

* Fix composer and renderer AOT JSON

* Outlook Sync AOT

* Fixing bundle generation and package signing.

---------

Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
2025-02-14 01:43:52 +01:00

45 lines
2.4 KiB
C#

using System;
using Microsoft.Extensions.DependencyInjection;
using Wino.Core.Domain.Models.Requests;
using Wino.Core.Domain.Models.Synchronization;
using Wino.Messaging.Server;
using Wino.Server.MessageHandlers;
namespace Wino.Server.Core
{
public class ServerMessageHandlerFactory : IServerMessageHandlerFactory
{
public ServerMessageHandlerBase GetHandler(string typeName)
{
return typeName switch
{
nameof(NewMailSynchronizationRequested) => App.Current.Services.GetService<MailSynchronizationRequestHandler>(),
nameof(NewCalendarSynchronizationRequested) => App.Current.Services.GetService<CalendarSynchronizationRequestHandler>(),
nameof(ServerRequestPackage) => App.Current.Services.GetService<UserActionRequestHandler>(),
nameof(DownloadMissingMessageRequested) => App.Current.Services.GetService<SingleMimeDownloadHandler>(),
nameof(AuthorizationRequested) => App.Current.Services.GetService<AuthenticationHandler>(),
nameof(SynchronizationExistenceCheckRequest) => App.Current.Services.GetService<SyncExistenceHandler>(),
nameof(ServerTerminationModeChanged) => App.Current.Services.GetService<ServerTerminationModeHandler>(),
nameof(TerminateServerRequested) => App.Current.Services.GetService<TerminateServerRequestHandler>(),
nameof(ImapConnectivityTestRequested) => App.Current.Services.GetService<ImapConnectivityTestHandler>(),
_ => throw new Exception($"Server handler for {typeName} is not registered."),
};
}
public void Setup(IServiceCollection serviceCollection)
{
// Register all known handlers.
serviceCollection.AddTransient<MailSynchronizationRequestHandler>();
serviceCollection.AddTransient<CalendarSynchronizationRequestHandler>();
serviceCollection.AddTransient<UserActionRequestHandler>();
serviceCollection.AddTransient<SingleMimeDownloadHandler>();
serviceCollection.AddTransient<AuthenticationHandler>();
serviceCollection.AddTransient<SyncExistenceHandler>();
serviceCollection.AddTransient<ServerTerminationModeHandler>();
serviceCollection.AddTransient<TerminateServerRequestHandler>();
serviceCollection.AddTransient<ImapConnectivityTestHandler>();
}
}
}