public Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); if (Found == null) { throw new InvalidOperationException($"The {nameof(ConventionRouter)} component requires a value for the parameter {nameof(Found)}"); } if (NotFound == null) { throw new InvalidOperationException($"The {nameof(ConventionRouter)} component requires a value for the parameter {nameof(NotFound)}"); } RouteManager.Initialize(); Refresh(); return(Task.CompletedTask); }
private void Refresh() { var relativeUri = NavigationManager.ToBaseRelativePath(_location); var parameters = ParseQueryString(relativeUri); if (relativeUri.IndexOf('?') > -1) { relativeUri = relativeUri.Substring(0, relativeUri.IndexOf('?')); } var segments = relativeUri.Trim().Split('/', StringSplitOptions.RemoveEmptyEntries); var matchResult = RouteManager.Match(segments); if (matchResult.IsMatch) { var routeData = new RouteData(matchResult.MatchedRoute.Handler, parameters); _renderHandle.Render(Found(routeData)); } else { _renderHandle.Render(NotFound); } }