示例#1
0
        private static void AddRouteData(PortalRequest request, PortalResponse response, Route route)
        {
            if (route == null)
            {
                return;
            }

            request.MergeTokens(route.GetTokens(request.Path));
            NameValueCollection queryString = request.QueryString;

            if (queryString.Count > 0)
            {
                RouteTokens queryTokens = new RouteTokens();
                foreach (string s in queryString)
                {
                    queryTokens.Add(s, queryString[s]);
                }
                request.MergeTokens(queryTokens);
            }

            request.ControllerName = route.ControllerName ?? request.GetTokenValue(ControllerNameToken);

            foreach (TileDefinition tile in route.Tiles)
            {
                response.Tiles.Add(tile);
            }

            if (!Compare.IsNullOrEmpty(route.PageTitle))
            {
                request.Title = FormattableObject.ToString(request.Tokens.ToDictonary(), route.PageTitle, null);
            }
        }
示例#2
0
        internal void MergeTokens(RouteTokens tokens)
        {
            if (tokens == null)
            {
                return;
            }

            if (Tokens == null)
            {
                Tokens = new RouteTokens();
            }

            Tokens.Merge(tokens);
        }
示例#3
0
        void IPortalRequest.AddToken(string name, string value)
        {
            Argument.Assert.IsNotNullOrEmpty(name, nameof(name));

            if (!Compare.IsNullOrEmpty(value))
            {
                value = value.Trim(segmentSeperatorCharArray);
            }

            if (Tokens == null)
            {
                Tokens = new RouteTokens();
            }
            Tokens.Add(name, value);
        }