Beispiel #1
0
        /// <summary>
        /// Initializes the view page to make sure expected properties are set.
        /// This is usually done when the MVC system "activates" a page, just before rendering it.
        /// </summary>
        /// <param name="httpcontext"></param>
        internal void ConfigureRequiredServices(HttpContext httpcontext)
        {
            if (ViewContext != null && ViewContext.HttpContext == null)
            {
                ViewContext.HttpContext = httpcontext;
            }

            // ... this makes sure the render current stack reference for the request is available ...

            if (ViewPageRenderStack == null)
            {
                ViewPageRenderStack = httpcontext.GetService <IViewPageRenderStack>(); // (IViewPageRenderStack is assumed to be a scoped service [per request])
            }
            // ... add the extension helper property ...

            if (XT == null)
            {
                XT = httpcontext.GetService <ViewHelper <TModel> >();
                if (XT != null && XT.View == null)
                {
                    XT.View = this;
                }
            }

            if (HostingEnvironment == null)
            {
                HostingEnvironment = httpcontext.GetService <IHostingEnvironment>();
            }
        }
        //x public ActionResult ViewResult { get; set; }

        public ViewPageRenderContext(IViewPageRenderStack viewStack)
        {
            ViewStack = viewStack;
        }