using WPFluent.Abstractions; using WPFluent.Controls; namespace WPFluent; /// /// A service that provides methods related to navigation. /// public partial class NavigationService(INavigationViewPageProvider pageProvider) : INavigationService { protected void ThrowIfNavigationControlIsNull() { if(NavigationControl is null) { throw new ArgumentNullException(nameof(NavigationControl)); } } /// /// Gets or sets the control representing navigation. /// protected INavigationView? NavigationControl { get; set; } /// public INavigationView GetNavigationControl() { return NavigationControl ?? throw new ArgumentNullException(nameof(NavigationControl)); } /// public bool GoBack() { ThrowIfNavigationControlIsNull(); return NavigationControl!.GoBack(); } /// public bool Navigate(Type pageType) { ThrowIfNavigationControlIsNull(); return NavigationControl!.Navigate(pageType); } /// public bool Navigate(string pageTag) { ThrowIfNavigationControlIsNull(); return NavigationControl!.Navigate(pageTag); } /// public bool Navigate(Type pageType, object? dataContext) { ThrowIfNavigationControlIsNull(); return NavigationControl!.Navigate(pageType, dataContext); } /// public bool Navigate(string pageTag, object? dataContext) { ThrowIfNavigationControlIsNull(); return NavigationControl!.Navigate(pageTag, dataContext); } /// public bool NavigateWithHierarchy(Type pageType) { ThrowIfNavigationControlIsNull(); return NavigationControl!.NavigateWithHierarchy(pageType); } /// public bool NavigateWithHierarchy(Type pageType, object? dataContext) { ThrowIfNavigationControlIsNull(); return NavigationControl!.NavigateWithHierarchy(pageType, dataContext); } /// public void SetNavigationControl(INavigationView navigation) { NavigationControl = navigation; NavigationControl.SetPageProviderService(pageProvider); } }