diff --git a/src/Artemis.UI.Shared/Routing/Route/IRouterRegistration.cs b/src/Artemis.UI.Shared/Routing/Route/IRouterRegistration.cs new file mode 100644 index 000000000..941bb43e3 --- /dev/null +++ b/src/Artemis.UI.Shared/Routing/Route/IRouterRegistration.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace Artemis.UI.Shared.Routing; + +/// +/// Represents a registration for a route. +/// +public interface IRouterRegistration +{ + /// + /// Gets the route associated with this registration. + /// + Route Route { get; } + + /// + /// Gets the type of the view model associated with the route. + /// + Type ViewModel { get; } + + /// + /// Gets or sets the child registrations of this route. + /// + List Children { get; set; } +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Route/ParameterParsers/IRouteParameterParser.cs b/src/Artemis.UI.Shared/Routing/Route/ParameterParsers/IRouteParameterParser.cs index 5851418e8..02ed8f21b 100644 --- a/src/Artemis.UI.Shared/Routing/Route/ParameterParsers/IRouteParameterParser.cs +++ b/src/Artemis.UI.Shared/Routing/Route/ParameterParsers/IRouteParameterParser.cs @@ -1,7 +1,23 @@ namespace Artemis.UI.Shared.Routing.ParameterParsers; +/// +/// Represents a contract for parsing route parameters. +/// public interface IRouteParameterParser { + /// + /// Checks if the given segment matches the provided source. + /// + /// The route segment to match. + /// The source value to match against the route segment. + /// if the segment matches the source; otherwise, . bool IsMatch(RouteSegment segment, string source); + + /// + /// Gets the parameter value from the provided source value. + /// + /// The route segment containing the parameter information. + /// The source value from which to extract the parameter value. + /// The extracted parameter value. object GetValue(RouteSegment segment, string source); } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Route/Route.cs b/src/Artemis.UI.Shared/Routing/Route/Route.cs index ad95bddd3..12ea6d4b4 100644 --- a/src/Artemis.UI.Shared/Routing/Route/Route.cs +++ b/src/Artemis.UI.Shared/Routing/Route/Route.cs @@ -3,15 +3,29 @@ using System.Linq; namespace Artemis.UI.Shared.Routing; +/// +/// Represents a route at a certain path. +/// public class Route { + /// + /// Initializes a new instance of the class. + /// + /// The path of the route. public Route(string path) { Path = path; Segments = path.Split('/').Select(s => new RouteSegment(s)).ToList(); } + /// + /// Gets the path of the route. + /// public string Path { get; } + + /// + /// Gets the list of segments that makes up the path. + /// public List Segments { get; } /// diff --git a/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs b/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs index dabb5dadb..2d9f8508f 100644 --- a/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs +++ b/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs @@ -1,12 +1,18 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Artemis.UI.Shared.Routing; +/// +/// Represents a registration for a route and its associated view model. +/// +/// The type of the view model associated with the route. public class RouteRegistration : IRouterRegistration where TViewModel : ViewModelBase { + /// + /// Initializes a new instance of the class. + /// + /// The path of the route. public RouteRegistration(string path) { Route = new Route(path); @@ -18,6 +24,9 @@ public class RouteRegistration : IRouterRegistration where TViewMode return $"{nameof(Route)}: {Route}, {nameof(ViewModel)}: {ViewModel}"; } + /// + /// Gets the route associated with this registration. + /// public Route Route { get; } /// @@ -25,12 +34,4 @@ public class RouteRegistration : IRouterRegistration where TViewMode /// public List Children { get; set; } = new(); -} - -public interface IRouterRegistration -{ - Route Route { get; } - Type ViewModel { get; } - List Children { get; set; } - } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Route/RouteSegment.cs b/src/Artemis.UI.Shared/Routing/Route/RouteSegment.cs index 77025b389..1f25b67da 100644 --- a/src/Artemis.UI.Shared/Routing/Route/RouteSegment.cs +++ b/src/Artemis.UI.Shared/Routing/Route/RouteSegment.cs @@ -4,10 +4,17 @@ using Artemis.UI.Shared.Routing.ParameterParsers; namespace Artemis.UI.Shared.Routing; +/// +/// Represents a segment of a route. +/// public partial class RouteSegment { private readonly IRouteParameterParser? _parameterParser; + /// + /// Initializes a new instance of the class. + /// + /// The segment value. public RouteSegment(string segment) { Segment = segment; @@ -21,10 +28,26 @@ public partial class RouteSegment } } + /// + /// Gets the segment value. + /// public string Segment { get; } + + /// + /// Gets the parameter name if the segment is a parameterized segment; otherwise . + /// public string? Parameter { get; } + + /// + /// Gets the type of the parameter if the segment is a parameterized segment; otherwise . + /// public string? ParameterType { get; } + /// + /// Checks if the segment matches the provided value. + /// + /// The value to compare with the segment. + /// if the segment matches the value; otherwise, . public bool IsMatch(string value) { if (_parameterParser == null) @@ -32,6 +55,11 @@ public partial class RouteSegment return _parameterParser.IsMatch(this, value); } + /// + /// Gets the parameter value from the provided value. + /// + /// The value from which to extract the parameter value. + /// The extracted parameter value. public object? GetParameter(string value) { if (_parameterParser == null) @@ -58,6 +86,10 @@ public partial class RouteSegment // Default to a string parser which just returns the segment as is } + /// + /// Gets the regular expression used to identify parameterized segments in the route. + /// + /// The regular expression pattern. [GeneratedRegex(@"\{(\w+):(\w+)\}")] private static partial Regex ParameterRegex(); } \ No newline at end of file