/// <summary> /// Gets the view for an input document (which is different than the view for a layout, partial, or /// other indirect view because it's not necessarily on disk or in the file system). /// </summary> private IView GetViewFromStream( string relativePath, Stream stream, string viewStartLocation, string layoutLocation, IRazorViewEngine viewEngine, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IRazorPageFactoryProvider pageFactoryProvider, IFileProvider rootFileProvider, IRazorCompilationService razorCompilationService) { IEnumerable <string> viewStartLocations = viewStartLocation != null ? new [] { viewStartLocation } : ViewHierarchyUtility.GetViewStartLocations(relativePath); List <IRazorPage> viewStartPages = viewStartLocations .Select(pageFactoryProvider.CreateFactory) .Where(x => x.Success) .Select(x => x.RazorPageFactory()) .Reverse() .ToList(); IRazorPage page = GetPageFromStream(relativePath, viewStartLocation, layoutLocation, stream, rootFileProvider, razorCompilationService); if (layoutLocation != null) { page.Layout = layoutLocation; } return(new RazorView(viewEngine, pageActivator, viewStartPages, page, htmlEncoder)); }
protected override IReadOnlyList <PageLookupItem> GetViewStartPages(string path) { var viewStartPages = new List <PageLookupItem>(); foreach (var viewStartPath in ViewHierarchyUtility.GetViewStartLocations(path)) { PageFactoryResult result = PageFactoryProvider.CreateFactory(viewStartPath); if (result.Success) { // Populate the viewStartPages list so that _ViewStarts appear in the order the need to be // executed (closest last, furthest first). This is the reverse order in which // ViewHierarchyUtility.GetViewStartLocations returns _ViewStarts. viewStartPages.Insert(0, new PageLookupItem(viewStartPath, result.PageFactory)); } } return(viewStartPages); }
/// <summary> /// Gets the view for an input document (which is different than the view for a layout, partial, or /// other indirect view because it's not necessarily on disk or in the file system). /// </summary> private IView GetViewFromStream(IServiceProvider serviceProvider, RenderRequest request, IRazorPage page) { IEnumerable <string> viewStartLocations = request.ViewStartLocation != null ? new[] { request.ViewStartLocation } : ViewHierarchyUtility.GetViewStartLocations(request.RelativePath); List <IRazorPage> viewStartPages = viewStartLocations .Select(serviceProvider.GetRequiredService <IRazorPageFactoryProvider>().CreateFactory) .Where(x => x.Success) .Select(x => x.RazorPageFactory()) .Reverse() .ToList(); if (request.LayoutLocation != null) { page.Layout = request.LayoutLocation; } IRazorViewEngine viewEngine = serviceProvider.GetRequiredService <IRazorViewEngine>(); IRazorPageActivator pageActivator = serviceProvider.GetRequiredService <IRazorPageActivator>(); HtmlEncoder htmlEncoder = serviceProvider.GetRequiredService <HtmlEncoder>(); return(new RazorView(viewEngine, pageActivator, viewStartPages, page, htmlEncoder)); }