-
-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathPageNavigationExtensions.cs
More file actions
44 lines (39 loc) · 1.46 KB
/
PageNavigationExtensions.cs
File metadata and controls
44 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Sentry.Internal;
namespace Sentry.Maui.Internal;
internal static class PageNavigationExtensions
{
#if !NET10_0_OR_GREATER
private static readonly PropertyInfo? DestinationPageProperty;
private static readonly PropertyInfo? PreviousPageProperty;
[UnconditionalSuppressMessage("Trimming", "IL2075: DynamicallyAccessedMembers", Justification = AotHelper.AvoidAtRuntime)]
static PageNavigationExtensions()
{
if (AotHelper.IsTrimmed)
{
return;
}
DestinationPageProperty = typeof(NavigatedFromEventArgs)
.GetProperty("DestinationPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
PreviousPageProperty = typeof(NavigatedToEventArgs)
.GetProperty("PreviousPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
#endif
/// <summary>
/// Gets the destination page from navigation arguments.
/// </summary>
public static Page? GetDestinationPage(this NavigatedFromEventArgs eventArgs) =>
#if NET10_0_OR_GREATER
eventArgs.DestinationPage;
#else
DestinationPageProperty?.GetValue(eventArgs) as Page;
#endif
/// <summary>
/// Gets the previous page from navigation arguments.
/// </summary>
public static Page? GetPreviousPage(this NavigatedToEventArgs eventArgs) =>
#if NET10_0_OR_GREATER
eventArgs.PreviousPage;
#else
PreviousPageProperty?.GetValue(eventArgs) as Page;
#endif
}