public object CreateInstance(string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            ViewMapping mapping;

            if (!_mappings.TryGetValue(virtualPath, out mapping))
            {
                return(null);
            }

            if (!mapping.ViewAssembly.PreemptPhysicalFiles && VirtualPathProvider.FileExists(virtualPath))
            {
                // If we aren't pre-empting physical files, use the BuildManager to create _ViewStart instances if the file exists on disk.
                return(BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(WebPageRenderingBase)));
            }

            if (mapping.ViewAssembly.UsePhysicalViewsIfNewer && mapping.ViewAssembly.IsPhysicalFileNewer(virtualPath))
            {
                // If the physical file on disk is newer and the user's opted in this behavior, serve it instead.
                return(BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(WebViewPage)));
            }

            return(_viewPageActivator.Create((ControllerContext)null, mapping.Type));
        }
        protected override bool FileExists(ControllerContext controllerContext, string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            ViewMapping mapping;

            if (!_mappings.TryGetValue(virtualPath, out mapping))
            {
                return(false);
            }

            if (mapping.ViewAssembly.UsePhysicalViewsIfNewer && mapping.ViewAssembly.IsPhysicalFileNewer(virtualPath))
            {
                // If the physical file on disk is newer and the user's opted in this behavior, serve it instead.
                return(false);
            }
            return(Exists(virtualPath));
        }
        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
        {
            viewPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(viewPath);

            return(CreateViewInternal(viewPath, masterPath, runViewStartPages: true));
        }
        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
        {
            partialPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(partialPath);

            return(CreateViewInternal(partialPath, masterPath: null, runViewStartPages: false));
        }
        public bool Exists(string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            return(_mappings.ContainsKey(virtualPath));
        }