using System;
namespace Artemis.UI.Shared.Routing;
///
/// Represents navigation options used to control navigation behaviour.
///
public class RouterNavigationOptions
{
///
/// Gets or sets a boolean indicating whether or not to add the navigation to the history.
///
public bool AddToHistory { get; set; } = true;
///
/// Gets or sets a boolean indicating whether or not to recycle already active screens.
///
public bool RecycleScreens { get; set; } = true;
///
/// Gets or sets a boolean indicating whether route changes should be ignored if they are a partial match.
///
/// If set to true, a route change from page/subpage1/subpage2 to page/subpage1 will be ignored.
public bool IgnoreOnPartialMatch { get; set; } = false;
///
/// Gets or sets the path to use when determining whether the path is a partial match,
/// only has any effect if is .
///
public string? PartialMatchOverride { get; set; }
///
/// Gets or sets a boolean value indicating whether logging should be enabled.
/// Errors and warnings are always logged.
///
public bool EnableLogging { get; set; } = true;
///
/// Determines whether the given two paths are considered equal using these navigation options.
///
/// The current path.
/// The target path.
/// if the paths are considered equal; otherwise .
internal bool PathEquals(string current, string target)
{
if (PartialMatchOverride != null && IgnoreOnPartialMatch)
target = PartialMatchOverride;
if (IgnoreOnPartialMatch)
return current.StartsWith(target, StringComparison.InvariantCultureIgnoreCase);
return string.Equals(current, target, StringComparison.InvariantCultureIgnoreCase);
}
}