Пример #1
0
        /// <summary>
        /// default constructor
        /// the route parameter can be obtained from NavigationManager.Uri on client or HttpContext.Request.GetEncodedUrl() on server
        /// the aliaspath parameter can be obtained from PageState.Alias.Path on client or TenantManager.GetAlias().Path on server
        /// </summary>
        public Route(string route, string aliaspath)
        {
            Uri uri = new Uri(route);

            Authority     = uri.Authority;
            Scheme        = uri.Scheme;
            Host          = uri.Host;
            Port          = uri.Port.ToString();
            Query         = uri.Query;
            Fragment      = uri.Fragment;
            AbsolutePath  = uri.AbsolutePath;
            AliasPath     = aliaspath;
            PagePath      = AbsolutePath;
            ModuleId      = "";
            Action        = "";
            UrlParameters = "";

            if (AliasPath.Length != 0 && PagePath.StartsWith("/" + AliasPath))
            {
                PagePath = PagePath.Substring(AliasPath.Length + 1);
            }
            int pos = PagePath.IndexOf("/" + Constants.UrlParametersDelimiter + "/");

            if (pos != -1)
            {
                UrlParameters = PagePath.Substring(pos + 3);
                PagePath      = PagePath.Substring(1, pos);
            }
            pos = PagePath.IndexOf("/" + Constants.ModuleDelimiter + "/");
            if (pos != -1)
            {
                ModuleId = PagePath.Substring(pos + 3);
                PagePath = PagePath.Substring(1, pos);
            }
            if (ModuleId.Length != 0)
            {
                pos = ModuleId.IndexOf("/");
                if (pos != -1)
                {
                    Action   = ModuleId.Substring(pos + 1);
                    ModuleId = ModuleId.Substring(0, pos);
                }
            }
            if (PagePath.StartsWith("/"))
            {
                PagePath = (PagePath.Length == 1) ? "" : PagePath.Substring(1);
            }
            if (PagePath.EndsWith("/"))
            {
                PagePath = PagePath.Substring(0, PagePath.Length - 1);
            }
        }