コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontRequestContext"/> class.
        /// </summary>
        /// <param name="site">The site.</param>
        /// <param name="page">The page.</param>
        /// <param name="requestChannel">The request channel.</param>
        /// <param name="httpContext">The HTTP context.</param>
        /// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
        public PageRequestContext(ControllerContext controllerContext, Site site, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
        {
            RouteValues = new RouteValueDictionary();

            this.ControllerContext = controllerContext;

            var httpContext = HttpContext.Current;

            this.Site           = site.AsActual();
            this.Page           = page.AsActual();
            this.RequestChannel = requestChannel;

            this.AllQueryString = new NameValueCollection(httpContext.Request.QueryString);


            HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
            var             routeData   = page.Route.ToMvcRoute().GetRouteData(pageContext);

            if (routeData != null)
            {
                RouteValues = routeData.Values;
                //Combine page parameters to [QueryString].
                foreach (var item in RouteValues)
                {
                    if (item.Value != null)
                    {
                        AllQueryString[item.Key] = item.Value.ToString();
                    }
                }
            }

            var moduleUrl = AllQueryString[ModuleUrlSegment];

            ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PageRequestContext" /> class.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="rawSite">The raw.</param>
        /// <param name="site">The site.</param>
        /// <param name="page">The page.</param>
        /// <param name="requestChannel">The request channel.</param>
        /// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
        public PageRequestContext(ControllerContext controllerContext, Site rawSite, Site site, Page rawPage, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
        {
            RouteValues = new RouteValueDictionary();

            this.ControllerContext = controllerContext;

            var httpContext = HttpContext.Current;

            this.RawSite        = rawSite;
            this.RawPage        = rawPage;
            this.Site           = site.AsActual();
            this.Page           = page.AsActual();
            this.RequestChannel = requestChannel;

            this.AllQueryString = new NameValueCollection();
            var queryString = httpContext.Request.QueryString;

            foreach (var key in queryString.AllKeys)
            {
                var value = queryString[key];
                if (!string.IsNullOrEmpty(value))
                {
                    AllQueryString[HttpUtility.HtmlEncode(key)] = HttpUtility.HtmlEncode(value);
                }
                else
                {
                    AllQueryString[HttpUtility.HtmlEncode(key)] = value;
                }
            }

            if (string.IsNullOrEmpty(pageRequestUrl))
            {
                pageRequestUrl = "/";
            }

            HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, Kooboo.Web.Url.UrlUtility.Combine("~", pageRequestUrl), ""));
            var             routeData   = page.Route.ToMvcRoute().GetRouteData(pageContext);

            if (routeData != null)
            {
                RouteValues = routeData.Values;
                //Combine page parameters to [QueryString].
                foreach (var item in RouteValues)
                {
                    if (item.Value != null)
                    {
                        AllQueryString[item.Key] = item.Value.ToString();
                    }
                }
            }

            var moduleUrl       = AllQueryString[ModuleUrlContext.ModuleUrlSegment];
            var modulePositions = page.PagePositions.Where(it => it is ModulePosition || it is ProxyPosition).Count();

            ModuleUrlContext = new ModuleUrlContext(this, moduleUrl, modulePositions);
        }
コード例 #3
0
ファイル: PageRequestContext.cs プロジェクト: Epitomy/CMS
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontRequestContext"/> class.
        /// </summary>
        /// <param name="site">The site.</param>
        /// <param name="page">The page.</param>
        /// <param name="requestChannel">The request channel.</param>
        /// <param name="httpContext">The HTTP context.</param>
        /// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
        public PageRequestContext(ControllerContext controllerContext, Site site, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
        {
            RouteValues = new RouteValueDictionary();

            this.ControllerContext = controllerContext;

            var httpContext = HttpContext.Current;

            this.Site = site.AsActual();
            this.Page = page.AsActual();
            this.RequestChannel = requestChannel;

            this.AllQueryString = new NameValueCollection(httpContext.Request.QueryString);

            HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
            var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);

            if (routeData != null)
            {
                RouteValues = routeData.Values;
                //Combine page parameters to [QueryString].
                foreach (var item in RouteValues)
                {
                    if (item.Value != null)
                    {
                        AllQueryString[item.Key] = item.Value.ToString();
                    }
                }
            }

            var moduleUrl = AllQueryString[ModuleUrlSegment];
            ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
        }
コード例 #4
0
ファイル: PageRequestContext.cs プロジェクト: rrsc/CMS
        /// <summary>
        /// Initializes a new instance of the <see cref="PageRequestContext" /> class.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="rawSite">The raw.</param>
        /// <param name="site">The site.</param>
        /// <param name="page">The page.</param>
        /// <param name="requestChannel">The request channel.</param>
        /// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
        public PageRequestContext(ControllerContext controllerContext, Site rawSite, Site site, Page rawPage, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
        {
            RouteValues = new RouteValueDictionary();

            this.ControllerContext = controllerContext;

            var httpContext = HttpContext.Current;

            this.RawSite = rawSite;
            this.RawPage = rawPage;
            this.Site = site.AsActual();
            this.Page = page.AsActual();
            this.RequestChannel = requestChannel;

            this.AllQueryString = new NameValueCollection();
            var queryString = httpContext.Request.QueryString;
            foreach (var key in queryString.AllKeys)
            {
                var value = queryString[key];
                if (!string.IsNullOrEmpty(value))
                {
                    AllQueryString[HttpUtility.HtmlEncode(key)] = HttpUtility.HtmlEncode(value);
                }
                else
                {
                    AllQueryString[HttpUtility.HtmlEncode(key)] = value;
                }

            }

            HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
            var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);

            if (routeData != null)
            {
                RouteValues = routeData.Values;
                //Combine page parameters to [QueryString].
                foreach (var item in RouteValues)
                {
                    if (item.Value != null)
                    {
                        AllQueryString[item.Key] = item.Value.ToString();
                    }
                }
            }

            var moduleUrl = AllQueryString[ModuleUrlContext.ModuleUrlSegment];
            ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
        }