コード例 #1
0
        public virtual void BeforeCompile(IBeforeCompileContext context)
        {
            var appEnv = _appServices.GetRequiredService <IApplicationEnvironment>();

            var setup = new RazorViewEngineOptionsSetup(appEnv);
            var sc    = new ServiceCollection();

            sc.ConfigureOptions(setup);
            sc.AddMvc();

            var viewCompiler = new RazorPreCompiler(BuildFallbackServiceProvider(sc, _appServices));

            viewCompiler.CompileViews(context);
        }
コード例 #2
0
        public virtual void BeforeCompile(IBeforeCompileContext context)
        {
            var sc     = new ServiceCollection();
            var appEnv = _appServices.GetRequiredService <IApplicationEnvironment>();

            var setup    = new RazorViewEngineOptionsSetup(appEnv);
            var accessor = new OptionsManager <RazorViewEngineOptions>(new[] { setup });

            sc.AddInstance <IOptions <RazorViewEngineOptions> >(accessor);
            sc.Add(MvcServices.GetDefaultServices());
            var sp = sc.BuildServiceProvider(_appServices);

            var viewCompiler = new RazorPreCompiler(sp);

            viewCompiler.CompileViews(context);
        }
コード例 #3
0
        public virtual void BeforeCompile(IBeforeCompileContext context)
        {
            var applicationEnvironment  = _appServices.GetRequiredService <IApplicationEnvironment>();
            var compilerOptionsProvider = _appServices.GetRequiredService <ICompilerOptionsProvider>();
            var compilationSettings     = compilerOptionsProvider.GetCompilationSettings(applicationEnvironment);

            var setup = new RazorViewEngineOptionsSetup(applicationEnvironment);
            var sc    = new ServiceCollection();

            sc.ConfigureOptions(setup);
            sc.AddMvc();

            var serviceProvider = BuildFallbackServiceProvider(sc, _appServices);
            var viewCompiler    = new RazorPreCompiler(serviceProvider, _memoryCache, compilationSettings);

            viewCompiler.CompileViews(context);
        }
コード例 #4
0
        /// <inheritdoc />
        /// <remarks>Pre-compiles all Razor views in the application.</remarks>
        public virtual void BeforeCompile(BeforeCompileContext context)
        {
            var compilerOptionsProvider = _appServices.GetRequiredService <ICompilerOptionsProvider>();
            var loadContextAccessor     = _appServices.GetRequiredService <IAssemblyLoadContextAccessor>();
            var compilationSettings     = GetCompilationSettings(compilerOptionsProvider, context.ProjectContext);
            var fileProvider            = new PhysicalFileProvider(context.ProjectContext.ProjectDirectory);

            var viewCompiler = new RazorPreCompiler(
                context,
                loadContextAccessor,
                fileProvider,
                _memoryCache,
                compilationSettings)
            {
                GenerateSymbols = GenerateSymbols
            };

            viewCompiler.CompileViews();
        }
コード例 #5
0
        /// <inheritdoc />
        /// <remarks>Pre-compiles all Razor views in the application.</remarks>
        public virtual void BeforeCompile(IBeforeCompileContext context)
        {
            var compilerOptionsProvider = _appServices.GetRequiredService<ICompilerOptionsProvider>();
            var loadContextAccessor = _appServices.GetRequiredService<IAssemblyLoadContextAccessor>();
            var compilationSettings = GetCompilationSettings(compilerOptionsProvider, context.ProjectContext);
            var fileProvider = new PhysicalFileProvider(context.ProjectContext.ProjectDirectory);

            var viewCompiler = new RazorPreCompiler(
                context,
                loadContextAccessor,
                fileProvider,
                _memoryCache,
                compilationSettings)
            {
                GenerateSymbols = GenerateSymbols
            };

            viewCompiler.CompileViews();
        }