Allow to embed precompiled razorviews (or any other webviewpage) Things that would be nice to have in Microsoft's code: - public access to VirtualPathFactoryManager.Instance - public access to VirtualPathFactoryManager.PageExists - let either store IVirtualPathFactory just the Type to construct instead of a constructor, or: let DictionaryBasedVirtualPathFactory use IoC if it's registered - allow to override BuildManager implementations, that way we could hook into the framework on that level, instead of creating an extra viewengine
Inheritance: System.Web.Mvc.VirtualPathProviderViewEngine
Beispiel #1
0
        protected void Application_Start()
        {
            ViewEngines.Engines.Clear();
            var engine = new CompiledRazorViewEngine();
            CompiledRazorViewEngine.RegisterViewAssembly(typeof(CompiledRazorViewEngine).Assembly);
            CompiledRazorViewEngine.RegisterViewAssembly(typeof(CompiledViews.Mvc3Test.Views._ViewStart).Assembly);
            ViewEngines.Engines.Add(engine);

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
Beispiel #2
0
        private Type GetViewStartType()
        {
            var vp = this.VirtualPath;

            while (vp.Contains("/Views/"))
            {
                vp = vp.Substring(0, vp.LastIndexOf("/"));
                var vs = CompiledRazorViewEngine.GetPageType(vp + "/_ViewStart.cshtml");
                if (vs != null)
                {
                    return(vs);
                }
            }
            return(null);
        }
Beispiel #3
0
        private dynamic GetLayout()
        {
            if (string.IsNullOrEmpty(Layout))
            {
                return(null);
            }
            var t = CompiledRazorViewEngine.GetPageType(Layout);

            if (t != null)
            {
                return(t.GetConstructor(new Type[] { }).Invoke(new object[] { }));
            }
            else
            {
                return(null);
            }
        }