예제 #1
0
        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);
            }
        }
        private void Refresh()
        {
            var relativeUri = NavigationManager.ToBaseRelativePath(_location);

            var currentCulture = LanguageService.CurrentCulture;

            var segment = relativeUri.IndexOf('/') > 0 ? relativeUri.Substring(0, relativeUri.IndexOf('/')) : null;

            if (segment == null)
            {
                NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
                return;
            }
            else
            {
                if (AllCultureInfos.Any(x => x.Name == segment))
                {
                    LanguageService.SetLanguage(CultureInfo.GetCultureInfo(segment));
                }
                else
                {
                    NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
                    return;
                }
            }

            var matchResult = RouteManager.Match(relativeUri);

            if (matchResult.IsMatch)
            {
                var routeData = new RouteData(matchResult.MatchedRoute.PageType, matchResult.MatchedRoute.Parameters);

                _renderHandle.Render(Found(routeData));
            }
            else
            {
                if (!string.IsNullOrEmpty(DefaultUrl))
                {
                    NavigationManager.NavigateTo($"{currentCulture}/{DefaultUrl}", true);
                }

                _renderHandle.Render(NotFound);
            }
        }
        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.Initialise(AppAssembly);
            Refresh();

            return(Task.CompletedTask);
        }
예제 #4
0
        private void Refresh()
        {
            var relativeUri = NavigationManager.ToBaseRelativePath(_location);

            if (relativeUri.IndexOf('?') > -1)
            {
                relativeUri = relativeUri.Substring(0, relativeUri.IndexOf('?'));
            }

            var matchResult = RouteManager.Match(relativeUri);

            if (matchResult.IsMatch)
            {
                var routeData = new RouteData(matchResult.MatchedRoute.PageType, matchResult.MatchedRoute.Parameters);

                _renderHandle.Render(Found(routeData));
            }
            else
            {
                _renderHandle.Render(NotFound);
            }
        }