예제 #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
        private void CreateContext(IHttpContext httpContext, string portalPath, string virtualPath, bool isPortalRoute)
        {
            foreach (VirtualResourcesElement resource in config.VirtualResources)
            {
                SetVirtualResourceData(resource.Name, new VirtualResourceData(resource.Namespace, resource.Assembly));
            }

            PortalRequest  request  = CreateRequest(httpContext, portalPath, virtualPath, isPortalRoute);
            PortalResponse response = new PortalResponse(this);

            Request  = request;
            Response = response;

            AddConfigOptions(this, request);

            if (isPortalRoute)
            {
                int firstSlashIndex = portalPath.IndexOf('/', 1);
                int length          = firstSlashIndex >= 0 ? firstSlashIndex : portalPath.Length;
                request.TenantName = TenantCache.GetTenantName(httpContext.Request.Url.Host);
                if (!Compare.IsNullOrEmpty(request.TenantName))
                {
                    request.VirtualPath = "/Tenants/" + request.TenantName + request.VirtualPath;
                }

                Section = TenantCache.GetSectionOrDefault(request.TenantName, portalPath.Length == 1 ? null : portalPath.Substring(1, length - 1));
                AddRouteContext(request, response, Section);
                AddControllerResult(this, request, Section);
            }

            PortalTrace.Write("PortalRequestModule", "CreateContext", "PortalContext created.");
            PortalTrace.Write("PortalRequestModule", "CreateContext", "Setup={0}, AllowPhysicalPages={1}, jQuery Version={2}", config.Setup, config.Routes.AllowPhysicalPages, config.JQuery.Version);
        }
예제 #3
0
        private static void AddRouteContext(PortalRequest request, PortalResponse response, SectionData section)
        {
            PortalTrace.Write("PortalRequestModule", "InitializeRouteContext", "Begin InitializeRouteContext.");

            if (section == null)
            {
                throw new InvalidOperationException("No section found.");
            }

            List <Route> routes = section.GetMatchedRoutes(request.Path);

            if (routes.Count > 0)
            {
                AddRouteData(request, response, routes[0]);
            }

            PortalTrace.Write("PortalRequestModule", "InitializeRouteContext", "End InitializeRouteContext.");
        }