fixed a bunch of isses with keyed handlers

This commit is contained in:
TheXamlGuy
2024-06-22 13:03:14 +01:00
parent 8d76b712be
commit 34d3cc313b
10 changed files with 77 additions and 109 deletions
+6 -6
View File
@@ -8,31 +8,31 @@ public class NavigateHandler(NamedComponent scope,
{
public Task Handle(NavigateEventArgs args)
{
INavigation? navigationScope = null;
INavigation? navigation = null;
if (args.Scope is "self" || args.Scope is "new")
{
if (args.Sender is IServiceProviderRequired requireServiceProvider)
{
if (args.Scope is "self")
{
navigationScope = requireServiceProvider.Provider.GetRequiredService<INavigation>();
navigation = requireServiceProvider.Provider.GetRequiredService<INavigation>();
}
if (args.Scope is "new")
{
IServiceScope serviceScope = requireServiceProvider.Provider.CreateScope();
navigationScope = serviceScope.ServiceProvider.GetRequiredService<INavigation>();
navigation = serviceScope.ServiceProvider.GetRequiredService<INavigation>();
}
}
}
if (navigationScope is null)
if (navigation is null)
{
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? scope.Name);
navigationScope = descriptor?.Services?.GetRequiredService<INavigation>();
navigation = descriptor?.Services?.GetRequiredService<INavigation>();
}
navigationScope?.Navigate(args.Route, args.Sender,
navigation?.Navigate(args.Route, args.Sender,
args.Region, args.Navigated, args.Parameters);
return Task.CompletedTask;