namespace WPFluent.Abstractions; /// /// Provides extension methods for the INavigationViewPageProvider interface. /// public static class NavigationViewPageProviderExtensions { /// /// Retrieves a page of the specified type from the page service. /// /// The type of the page to retrieve. /// The page service instance. /// An instance of the specified page type, or null if the page is not found. public static TPage? GetPage(this INavigationViewPageProvider navigationViewPageProvider) where TPage : class { return navigationViewPageProvider.GetPage(typeof(TPage)) as TPage; } /// /// Retrieves a page of the specified type from the page service. Throws a NavigationException if the page is not /// found. /// /// The type of the page to retrieve. /// The page service instance. /// An instance of the specified page type. /// Thrown when the specified page type is not found. public static TPage GetRequiredPage(this INavigationViewPageProvider navigationViewPageProvider) where TPage : class { return navigationViewPageProvider.GetPage(typeof(TPage)) as TPage ?? throw new NavigationException($"{typeof(TPage)} page not found."); } }