Skip to content

Commit

Permalink
feat: Add mapping caching when using reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Jan 4, 2024
1 parent 7cd37ad commit 5f64659
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ view is null &&
});
Mappings.Add(defaultMapFromViewMap);
if (Logger.IsEnabled(LogLevel.Debug)) Logger.LogDebugMessage($"Created default mapping from viewmap - Path '{defaultMapFromViewMap.Path}'");
return defaultMapFromViewMap;
}

if (Logger.IsEnabled(LogLevel.Information)) Logger.LogInformationMessage($"For better performance (avoid reflection), create mapping for for path '{path}', view '{view?.Name}', view model '{viewModel?.Name}'");
Expand All @@ -134,6 +135,7 @@ view is null &&
return IsDialogViewType(view);
});
if (Logger.IsEnabled(LogLevel.Debug)) Logger.LogDebugMessage($"Created default mapping - Path '{defaultMap.Path}'");
Mappings.Add(defaultMap);
return defaultMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</Grid.Resources>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
Expand All @@ -29,8 +30,9 @@
Grid.Row="1"
x:Name="CurrentTabBarItemText"
AutomationProperties.AutomationId="CurrentTabBarItemTextBlock" />
<ToggleButton Grid.Row="2" Content="ImplicitMapping" IsChecked="{Binding ImplicitMappingEnabled}" Command="{Binding ToggleIsCheckedCommand}" />
<Grid uen:Region.Attached="true"
Grid.Row="2" >
Grid.Row="3" >
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
namespace TestHarness.Ext.Navigation.TabBar;

public record TabBarHomeViewModel(INavigator Navigator)
public partial class TabBarHomeViewModel : ObservableObject
{
private RouteResolverDefault routeResolver;
public TabBarHomeViewModel(IServiceProvider services)
{
routeResolver = services.GetRequiredService<RouteResolverDefault>();
ImplicitMappingEnabled = routeResolver.ReturnImplicitMapping;
}

[ObservableProperty]
private bool _implicitMappingEnabled;

[RelayCommand]
public void ToggleIsChecked()
{
routeResolver.ReturnImplicitMapping = !routeResolver.ReturnImplicitMapping;
ImplicitMappingEnabled = routeResolver.ReturnImplicitMapping;
}
}

0 comments on commit 5f64659

Please sign in to comment.