示例#1
0
 public MvcRazorRuntimeCompilationOptionsConfiguration(IFeatureMetadataProvider metadataProvider,
                                                       IFeatureChangeTokenProvider tokenProvider, FeatureRuntimeCompilationOptions options)
 {
     _metadataProvider = metadataProvider;
     _tokenProvider    = tokenProvider;
     _options          = options;
 }
 private static void AddRazorRuntimeCompilation(this IMvcBuilder mvcBuilder, FeatureRuntimeCompilationOptions options)
 {
     RazorRuntimeCompilationMvcCoreBuilderExtensions.AddServices(mvcBuilder.Services);
     mvcBuilder.Services.ConfigureOptions <MvcRazorRuntimeCompilationOptionsConfiguration>();
 }
        public static IMvcBuilder AddFeatureRuntimeCompilation(this IMvcBuilder mvcBuilder, FeatureRuntimeCompilationOptions options)
        {
            var services = mvcBuilder.Services;

            // ASP.NET (Http, Routing, Razor)
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <EndpointSelector, FeatureEndpointSelector>();
            services.AddSingleton <RazorReferenceManager, FeatureRazorReferenceManager>();
            services.AddSingleton <FeatureActionDescriptorChangeProvider>();
            services.AddSingleton <IActionDescriptorChangeProvider>(sp => sp.GetService <FeatureActionDescriptorChangeProvider>());

            mvcBuilder.AddRazorRuntimeCompilation(options);

            // Compilation
            services.AddSingleton(options);
            services.AddSingleton <FeatureRuntimeCompilationWatcher>();
            services.AddTransient <IFeatureMetadataProvider, FeatureMetadataProvider>();
            services.AddSingleton <IFeatureUpdater, FeatureUpdater>();
            services.AddSingleton <IFeatureApplicationPartManager, FeatureApplicationPartManager>();
            services.AddSingleton <IFeatureCache, FeatureCache>();
            services.AddSingleton <IFeatureCompiler, FeatureCompiler>();
            services.AddTransient <IFeatureChecksumGenerator, FeatureChecksumGenerator>();
            services.AddSingleton <IFeatureChangeTokenProvider, FeatureChangeTokenProvider>();

            // Setup
            if (Directory.Exists(options.AssembliesOutputPath))
            {
                Directory.Delete(options.AssembliesOutputPath, true);
            }

            Directory.CreateDirectory(options.AssembliesOutputPath);

            FeatureAssemblyLocator.Init();

            return(mvcBuilder);
        }