/// <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) { StatiqRazorProjectFileSystem projectFileSystem = serviceProvider.GetRequiredService <StatiqRazorProjectFileSystem>(); IEnumerable <string> viewStartLocations = request.ViewStartLocation != null ? new[] { request.ViewStartLocation } : projectFileSystem.FindHierarchicalItems(request.RelativePath, ViewStartFileName).Select(x => x.FilePath); 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>(); DiagnosticSource diagnosticSource = serviceProvider.GetRequiredService <DiagnosticSource>(); return(new RazorView(viewEngine, pageActivator, viewStartPages, page, htmlEncoder, diagnosticSource)); }
/// <summary> /// /// </summary> /// <param name="engine"></param> /// <param name="cSharpCompiler"></param> /// <param name="applicationPartManager"></param> /// <param name="tempDataDictionaryFactory"></param> /// <param name="razorViewEngineFileProviderAccessor"></param> /// <param name="razorPageActivator"></param> /// <param name="htmlEncoder"></param> /// <param name="razorPageFactoryProvider"></param> /// <param name="httpContextAccessor"></param> /// <param name="projectCacheProvider"></param> /// <param name="loggerFactory"></param> /// <param name="razorEngineOptions"></param> /// <param name="mvcViewOptions"></param> /// <param name="diagnosticSource"></param> public DynamicRazorEngine(RazorEngine engine, CSharpCompiler cSharpCompiler, ApplicationPartManager applicationPartManager, ITempDataDictionaryFactory tempDataDictionaryFactory, IRazorViewEngineFileProviderAccessor razorViewEngineFileProviderAccessor, IRazorPageActivator razorPageActivator, HtmlEncoder htmlEncoder, IRazorPageFactoryProvider razorPageFactoryProvider, IHttpContextAccessor httpContextAccessor, IDynamicRazorProjectCacheProvider projectCacheProvider, ILoggerFactory loggerFactory, IOptions <RazorViewEngineOptions> razorEngineOptions, IOptions <MvcViewOptions> mvcViewOptions, DiagnosticSource diagnosticSource, IServiceProvider serviceProvider) { _engine = engine; _tempDataDictionaryFactory = tempDataDictionaryFactory; _razorViewEngineFileProviderAccessor = razorViewEngineFileProviderAccessor; _cSharpCompiler = cSharpCompiler; _razorEngineOptions = razorEngineOptions; _applicationPartManager = applicationPartManager; _loggerFactory = loggerFactory; _razorPageActivator = razorPageActivator; _htmlEncoder = htmlEncoder; _httpContextAccessor = httpContextAccessor; _projectCacheProvider = projectCacheProvider; _diagnosticSource = diagnosticSource; _mvcViewOptions = mvcViewOptions; _razorPageFactoryProvider = razorPageFactoryProvider; _serviceProvider = serviceProvider; }
public PageRenderer(IRazorViewEngine viewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider, IRazorPageActivator activator, IHostingEnvironment hostingEnvironment) { _viewEngine = viewEngine; _tempDataProvider = tempDataProvider; _serviceProvider = serviceProvider; _activator = activator; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine" />. /// </summary> public RazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, RazorProject razorProject, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) { _options = optionsAccessor.Value; if (_options.ViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.ViewLocationFormats)), nameof(optionsAccessor)); } if (_options.AreaViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.AreaViewLocationFormats)), nameof(optionsAccessor)); } _pageFactory = pageFactory; _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _logger = loggerFactory.CreateLogger <RazorViewEngine>(); _razorProject = razorProject; _diagnosticSource = diagnosticSource; ViewLookupCache = new MemoryCache(new MemoryCacheOptions()); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine" />. /// </summary> public RazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory) { _options = optionsAccessor.Value; if (_options.ViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.ViewLocationFormats)), nameof(optionsAccessor)); } if (_options.AreaViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.AreaViewLocationFormats)), nameof(optionsAccessor)); } _pageFactory = pageFactory; _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _logger = loggerFactory.CreateLogger <RazorViewEngine>(); ViewLookupCache = new MemoryCache(new MemoryCacheOptions { CompactOnMemoryPressure = false }); }
public WidgetProvider( IRazorViewEngine viewEngine, IRazorPageActivator pageActivator, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider, IModelMetadataProvider modelMetadataProvider, IHttpContextAccessor httpContextAccessor, IViewComponentHelper componentHelper, IEnumerable <IWidgetNamedModelProvider> namedModelProviders, IContextAccessor <SiteContext> siteContextAccessor, IContextAccessor <UserContext> userContextAccessor, PluginContext pluginContext ) { _viewEngine = viewEngine; _pageActivator = pageActivator; _tempDataProvider = tempDataProvider; _serviceProvider = serviceProvider; _modelMetadataProvider = modelMetadataProvider; _componentHelper = componentHelper as DefaultViewComponentHelper; _httpContextAccessor = httpContextAccessor; _siteContextAccessor = siteContextAccessor; _userContextAccessor = userContextAccessor; _pluginContext = pluginContext; _namedModelProviders = namedModelProviders; Widgets = pluginContext.GetData <WidgetConfig>(); }
/// <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)); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine" />. /// </summary> public CustomRazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory, DiagnosticListener diagnosticListener) { _options = optionsAccessor.Value; if (_options.ViewLocationFormats.Count == 0) { throw new ArgumentException( $"required {nameof(RazorViewEngineOptions.ViewLocationFormats)}", nameof(optionsAccessor)); } if (_options.AreaViewLocationFormats.Count == 0) { throw new ArgumentException( $"required {nameof(RazorViewEngineOptions.AreaViewLocationFormats)}", nameof(optionsAccessor)); } _pageFactory = pageFactory; _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _logger = loggerFactory.CreateLogger <RazorViewEngine>(); _diagnosticListener = diagnosticListener; ViewLookupCache = new MemoryCache(new MemoryCacheOptions()); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine" />. /// </summary> public RazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions<RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory) { _options = optionsAccessor.Value; if (_options.ViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.ViewLocationFormats)), nameof(optionsAccessor)); } if (_options.AreaViewLocationFormats.Count == 0) { throw new ArgumentException( Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.AreaViewLocationFormats)), nameof(optionsAccessor)); } _pageFactory = pageFactory; _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _logger = loggerFactory.CreateLogger<RazorViewEngine>(); ViewLookupCache = new MemoryCache(new MemoryCacheOptions { CompactOnMemoryPressure = false }); }
/// <summary> /// Initializes a new instance of the RazorViewEngine class. /// </summary> /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/>.</param> /// <param name="pageActivator">Activator for activated instances of <see cref="IRazorPage"/>.</param> /// <param name="viewStartProvider">The provider used to provide instances of ViewStarts applicable to the /// page being rendered.</param> public RazorViewEngine(IRazorPageFactory pageFactory, IRazorPageActivator pageActivator, IViewStartProvider viewStartProvider) { _pageFactory = pageFactory; _pageActivator = pageActivator; _viewStartProvider = viewStartProvider; }
public SimpleRazorViewEngine(IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory) : base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, loggerFactory) { optionsAccessor.Value.ViewLocationFormats.Clear(); optionsAccessor.Value.ViewLocationFormats.Add("~/wwwroot/app/components/{1}/{0}.html"); optionsAccessor.Value.ViewLocationFormats.Add("~/wwwroot/app/{1}/{0}.html"); optionsAccessor.Value.ViewLocationFormats.Add("~/wwwroot/app/{0}.html"); }
/// <summary> /// Initializes a new instance of RazorViewFactory /// </summary> /// <param name="pageActivator">The <see cref="IRazorPageActivator"/> used to activate pages.</param> /// <param name="viewStartProvider">The <see cref="IViewStartProvider"/> used for discovery of _ViewStart /// pages</param> public RazorViewFactory( IRazorPageActivator pageActivator, IViewStartProvider viewStartProvider, IHtmlEncoder htmlEncoder) { _pageActivator = pageActivator; _viewStartProvider = viewStartProvider; _htmlEncoder = htmlEncoder; }
/// <summary> /// Initializes a new instance of the <see cref="MinifiedRazorViewEngine" /> class. /// </summary> /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param> public MinifiedRazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory) : base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, loggerFactory) { }
public GlobalRazorHelpersFactory(ICompositeViewEngine viewEngine, IRazorPageActivator razorPageActivator, IOptions <GlobalRazorHelpersOptions>?options) { _viewEngine = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine)); _razorPageActivator = razorPageActivator ?? throw new ArgumentNullException(nameof(razorPageActivator)); var optionsValue = options?.Value; _helpersTypeViewPathMappings = new ConcurrentDictionary <Type, string>(optionsValue?.HelpersTypeViewPathMappings ?? Enumerable.Empty <KeyValuePair <Type, string> >()); }
public CustomRazorPageActivator( IModelMetadataProvider metadataProvider, IUrlHelperFactory urlHelperFactory, IJsonHelper jsonHelper, DiagnosticSource diagnosticSource, HtmlEncoder htmlEncoder, IModelExpressionProvider modelExpressionProvider) { this._activator = new RazorPageActivator(metadataProvider, urlHelperFactory, jsonHelper, diagnosticSource, htmlEncoder, modelExpressionProvider); }
public PageResultExecutor( IHttpResponseStreamWriterFactory writerFactory, IRazorViewEngine razorViewEngine, IRazorPageActivator razorPageActivator, HtmlEncoder htmlEncoder) { WriterFactory = writerFactory; _razorViewEngine = razorViewEngine; _razorPageActivator = razorPageActivator; _htmlEncoder = htmlEncoder; }
public static async Task <string> RenderViewAsync(this PageModel pageModel, string pageName) { var actionContext = new ActionContext( pageModel.HttpContext, pageModel.RouteData, pageModel.PageContext.ActionDescriptor ); using (var sw = new StringWriter()) { IRazorViewEngine _razorViewEngine = pageModel.HttpContext.RequestServices.GetService(typeof(IRazorViewEngine)) as IRazorViewEngine; IRazorPageActivator _activator = pageModel.HttpContext.RequestServices.GetService(typeof(IRazorPageActivator)) as IRazorPageActivator; var result = _razorViewEngine.FindPage(actionContext, pageName); if (result.Page == null) { throw new ArgumentNullException($"The page {pageName} cannot be found."); } var page = result.Page; var view = new RazorView(_razorViewEngine, _activator, new List <IRazorPage>(), page, HtmlEncoder.Default, new DiagnosticListener("ViewRenderService")); var viewContext = new ViewContext( actionContext, view, pageModel.ViewData, pageModel.TempData, sw, new HtmlHelperOptions() ); var pageNormal = ((Page)result.Page); pageNormal.PageContext = pageModel.PageContext; pageNormal.ViewContext = viewContext; _activator.Activate(pageNormal, viewContext); await page.ExecuteAsync(); return(sw.ToString()); } }
/// <summary> /// Initializes a new instance of RazorView /// </summary> /// <param name="page">The page to execute</param> /// <param name="pageFactory">The view factory used to instantiate additional views.</param> /// <param name="pageActivator">The <see cref="IRazorPageActivator"/> used to activate pages.</param> /// <param name="executeViewHierarchy">A value that indiciates whether the view hierarchy that involves /// view start and layout pages are executed as part of the executing the page.</param> public RazorView([NotNull] IRazorPageFactory pageFactory, [NotNull] IRazorPageActivator pageActivator, [NotNull] IViewStartProvider viewStartProvider, [NotNull] IRazorPage page, bool executeViewHierarchy) { _pageFactory = pageFactory; _pageActivator = pageActivator; _viewStartProvider = viewStartProvider; _page = page; _executeViewHierarchy = executeViewHierarchy; }
/// <summary> /// Initializes a new instance of <see cref="RazorView"/> /// </summary> /// <param name="viewEngine">The <see cref="IRazorViewEngine"/> used to locate Layout pages.</param> /// <param name="pageActivator">The <see cref="IRazorPageActivator"/> used to activate pages.</param> /// <param name="viewStartProvider">The <see cref="IViewStartProvider"/> used for discovery of _ViewStart /// <param name="razorPage">The <see cref="IRazorPage"/> instance to execute.</param> /// <param name="isPartial">Determines if the view is to be executed as a partial.</param> /// pages</param> public RazorView(IRazorViewEngine viewEngine, IRazorPageActivator pageActivator, IViewStartProvider viewStartProvider, IRazorPage razorPage, bool isPartial) { _viewEngine = viewEngine; _pageActivator = pageActivator; _viewStartProvider = viewStartProvider; RazorPage = razorPage; IsPartial = isPartial; }
//public CompositePrecompiledMvcEngine() { } /// <inheritdoc /> public CompositePrecompiledMvcEngine(IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, RazorProjectFileSystem razorFileSystem, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) : base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticSource) { _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _diagnosticSource = diagnosticSource; }
/// <summary> /// Initializes a new instance of the RazorViewEngine /// </summary> public RazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, RazorProjectFileSystem razorFileSystem, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) #pragma warning disable CS0618 // Type or member is obsolete : this(pageFactory, pageActivator, htmlEncoder, optionsAccessor, (RazorProject)razorFileSystem, loggerFactory, diagnosticSource) #pragma warning restore CS0618 // Type or member is obsolete { }
public CustomRazorViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, RazorProjectFileSystem razorFileSystem, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) : base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticSource) { }
public TemplateEngine( IRazorViewEngine engine, TemplateRazorEngine myEngine, IRazorPageFactoryProvider factoryProvider, IRazorPageActivator razorPageActivator, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider) { _engine = engine; _tempDataProvider = tempDataProvider; _serviceProvider = serviceProvider; _myEngine = myEngine; }
public ViewRenderService( IRazorViewEngine razorViewEngine, ITempDataProvider tempDataProvider, IHttpContextAccessor httpContext, IRazorPageActivator activator, IActionContextAccessor actionContextAccessor) { this.razorViewEngine = razorViewEngine; this.tempDataProvider = tempDataProvider; this.httpContext = httpContext; this.actionContextAccessor = actionContextAccessor; this.activator = activator; }
public RazorPageRenderingService( IRazorViewEngine engine, IRazorPageActivator activator, ITempDataProvider tempDataProvider, IHttpContextAccessor httpContextAccessor ) { _engine = engine; _activator = activator; _tempDataProvider = tempDataProvider; _httpContextAccessor = httpContextAccessor; }
public PlatoViewEngine( IRazorPageFactoryProvider pageFactory, IOptions <RazorViewEngineOptions> optionsAccessor, DiagnosticListener diagnosticListener, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder) { _diagnosticListener = diagnosticListener; _options = optionsAccessor.Value; _pageActivator = pageActivator; _pageFactory = pageFactory; _htmlEncoder = htmlEncoder; ViewLookupCache = new MemoryCache(new MemoryCacheOptions()); }
public RazorPageAsPdf(PageModel pageModel) { PageModel = pageModel; var httpContext = pageModel.HttpContext; _razorPageName = httpContext.Request.RouteValues["page"].ToString().Trim('/'); if (string.IsNullOrEmpty(_razorPageName)) { throw new ArgumentException("there's no such a 'page' in this context"); } _razorViewEngine = httpContext.RequestServices.GetRequiredService <IRazorViewEngine>(); _tempDataProvider = httpContext.RequestServices.GetRequiredService <ITempDataProvider>(); _activator = httpContext.RequestServices.GetRequiredService <IRazorPageActivator>(); }
/// <summary> /// Creates a new <see cref="PageResultExecutor"/>. /// </summary> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="compositeViewEngine">The <see cref="ICompositeViewEngine"/>.</param> /// <param name="razorViewEngine">The <see cref="IRazorViewEngine"/>.</param> /// <param name="razorPageActivator">The <see cref="IRazorPageActivator"/>.</param> /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param> /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param> public PageResultExecutor( IHttpResponseStreamWriterFactory writerFactory, ICompositeViewEngine compositeViewEngine, IRazorViewEngine razorViewEngine, IRazorPageActivator razorPageActivator, DiagnosticSource diagnosticSource, HtmlEncoder htmlEncoder) : base(writerFactory, compositeViewEngine, diagnosticSource) { _razorViewEngine = razorViewEngine; _htmlEncoder = htmlEncoder; _razorPageActivator = razorPageActivator; _diagnosticSource = diagnosticSource; }
//IRazorViewEngine public CoreViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions <RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory ) : base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, loggerFactory) { //https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs // {0} represents the name of the view // {1} represents the name of the controller // {2} represents the name of the area }
public RazorRenderService(IRazorViewEngine razorViewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider, IHttpContextAccessor httpContext, IRazorPageActivator activator, IActionContextAccessor actionContext) { _razorViewEngine = razorViewEngine; _tempDataProvider = tempDataProvider; _serviceProvider = serviceProvider; _httpContext = httpContext; _actionContext = actionContext; _activator = activator; }
public TemplateRazorEngine( TemplateFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, OptionsManager <TemplateOptions> optionsAccessor, RazorProjectFileSystem razorFileSystem, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) : base( pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticSource) { }
//IRazorViewEngine public CoreViewEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions<RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory ) :base(pageFactory, pageActivator, htmlEncoder, optionsAccessor, loggerFactory) { //https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs // {0} represents the name of the view // {1} represents the name of the controller // {2} represents the name of the area }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine" />. /// </summary> public MultiTemplateEngine( IRazorPageFactoryProvider pageFactory, IRazorPageActivator pageActivator, HtmlEncoder htmlEncoder, IOptions<RazorViewEngineOptions> optionsAccessor, ILoggerFactory loggerFactory) { _options = optionsAccessor.Value; _pageFactory = pageFactory; _pageActivator = pageActivator; _htmlEncoder = htmlEncoder; _logger = loggerFactory.CreateLogger<RazorViewEngine>(); ViewLookupCache = new MemoryCache(new MemoryCacheOptions { CompactOnMemoryPressure = false }); }
/// <summary> /// Initializes a new instance of <see cref="RazorView"/> /// </summary> /// <param name="viewEngine">The <see cref="IRazorViewEngine"/> used to locate Layout pages.</param> /// <param name="pageActivator">The <see cref="IRazorPageActivator"/> used to activate pages.</param> /// <param name="viewStartPages">The sequence of <see cref="IRazorPage" /> instances executed as _ViewStarts. /// </param> /// <param name="razorPage">The <see cref="IRazorPage"/> instance to execute.</param> /// <param name="htmlEncoder">The HTML encoder.</param> public RazorView( IRazorViewEngine viewEngine, IRazorPageActivator pageActivator, IReadOnlyList<IRazorPage> viewStartPages, IRazorPage razorPage, HtmlEncoder htmlEncoder) { if (viewEngine == null) { throw new ArgumentNullException(nameof(viewEngine)); } if (pageActivator == null) { throw new ArgumentNullException(nameof(pageActivator)); } if (viewStartPages == null) { throw new ArgumentNullException(nameof(viewStartPages)); } if (razorPage == null) { throw new ArgumentNullException(nameof(razorPage)); } if (htmlEncoder == null) { throw new ArgumentNullException(nameof(htmlEncoder)); } _viewEngine = viewEngine; _pageActivator = pageActivator; ViewStartPages = viewStartPages; RazorPage = razorPage; _htmlEncoder = htmlEncoder; }