Skip to content

Commit

Permalink
Update RegionNavigationRegistrationExtensions.cs
Browse files Browse the repository at this point in the history
My previous submission made RegisterForNavigationWithViewModel public, after more thought it makes sense that it would be private and instead an override of RegisterForRegionNavigation without the strong typing is more descriptive and conveys the intent better.
  • Loading branch information
jpislas authored May 22, 2024
1 parent 17c6d31 commit cce2033
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public static class RegionNavigationRegistrationExtensions
where TViewModel : class =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), typeof(TViewModel), name);

public static IContainerRegistry RegisterForNavigationWithViewModel(this IContainerRegistry containerRegistry, Type viewType, Type viewModelType, string name)
public static IContainerRegistry RegisterForRegionNavigation(this IContainerRegistry containerRegistry, Type viewType, Type viewModelType, string name = null)
=> containerRegistry.RegisterForNavigationWithViewModel(viewType, viewModelType, name);

private static IContainerRegistry RegisterForNavigationWithViewModel(this IContainerRegistry containerRegistry, Type viewType, Type viewModelType, string name)
{
if (string.IsNullOrWhiteSpace(name))
name = viewType.Name;
Expand Down Expand Up @@ -77,6 +80,9 @@ public static IContainerRegistry RegisterForNavigationWithViewModel(this IContai
where TViewModel : class =>
services.RegisterForNavigationWithViewModel(typeof(TView), typeof(TViewModel), name);

public static IServiceCollection RegisterForRegionNavigation(this IServiceCollection services, Type viewType, Type viewModelType, string name = null)
=> services.RegisterForNavigationWithViewModel(viewType, viewModelType, name);

private static IServiceCollection RegisterForNavigationWithViewModel(this IServiceCollection services, Type viewType, Type viewModelType, string name)
{
if (string.IsNullOrWhiteSpace(name))
Expand Down

0 comments on commit cce2033

Please sign in to comment.