Improve Publisher

This commit is contained in:
TheXamlGuy
2024-05-14 19:24:07 +01:00
parent 06be638af8
commit 819d796c16
22 changed files with 91 additions and 58 deletions
+5 -3
View File
@@ -9,16 +9,18 @@ namespace Bitvault.Avalonia;
public class AppHandler(IPublisher publisher) :
INotificationHandler<StartedEventArgs>
{
public async Task Handle(StartedEventArgs args, CancellationToken cancellationToken = default)
public Task Handle(StartedEventArgs args)
{
if (Application.Current is Application application)
{
if (application.ApplicationLifetime is IApplicationLifetime lifetime)
{
await publisher.Publish(new NavigateEventArgs(lifetime is IClassicDesktopStyleApplicationLifetime ? "MainWindow" : "Main",
publisher.Publish(new NavigateEventArgs(lifetime is IClassicDesktopStyleApplicationLifetime ? "MainWindow" : "Main",
lifetime is IClassicDesktopStyleApplicationLifetime ? typeof(IClassicDesktopStyleApplicationLifetime) :
typeof(ISingleViewApplicationLifetime)), cancellationToken);
typeof(ISingleViewApplicationLifetime)));
}
}
return Task.CompletedTask;
}
}