Пример #1
0
        public static void HotSetup(this IServiceCollection services, IMvcBuilder mvcBuilder)
        {
            _serviceCollection = services;
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IMvcModuleSetup, MvcModuleSetup>();
            services.AddSingleton <IServiceCollection>(services);
            // services.AddScoped<IDbHelper, DbHelper>();
            services.AddSingleton <IActionDescriptorChangeProvider>(InBizActionDescriptorChangeProvider.Instance);
            services.AddSingleton <IReferenceContainer, DefaultReferenceContainer>();
            services.AddSingleton <IReferenceLoader, DefaultReferenceLoader>();
            services.AddSingleton(InBizActionDescriptorChangeProvider.Instance);
            // IMvcBuilder mvcBuilder = services.AddMvc();
            ServiceProvider provider = services.BuildServiceProvider();

            using (IServiceScope scope = provider.CreateScope())
            {
                var contextProvider = new CollectibleAssemblyLoadContextProvider();
                var context         = contextProvider.Get("DemoPlugin1", services, mvcBuilder.PartManager, scope);
                if (context != null)
                {
                    PluginsLoadContexts.Add("DemoPlugin1", context);
                }
            }
            AssemblyLoadContextResoving();
            services.Configure <RazorViewEngineOptions>(o =>
            {
                o.AreaViewLocationFormats.Add("/Modules/{2}/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
                o.AreaViewLocationFormats.Add("/Views/Shared/{0}.cshtml");
            });

            services.Replace <IViewCompilerProvider, InBizViewCompilerProvider>();
        }
Пример #2
0
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.TryAddSingleton <InBizModuleLoader>();
            context.Services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            context.Services.TryAddSingleton <IMvcModuleSetup, MvcModuleSetup>();
            context.Services.TryAddSingleton <IReferenceContainer, DefaultReferenceContainer>();
            context.Services.TryAddSingleton <IReferenceLoader, DefaultReferenceLoader>();

            ServiceProvider provider    = context.Services.BuildServiceProvider();
            var             partManager = context.Services.GetSingletonInstance <ApplicationPartManager>();

            using (IServiceScope scope = provider.CreateScope())
            {
                var contextProvider = new CollectibleAssemblyLoadContextProvider();
                var pluginContext   = contextProvider.Get("DemoPlugin2", context.Services, partManager, scope);
                PluginsLoadContexts.Add("DemoPlugin2", pluginContext);
            }
            AssemblyLoadContextResoving();
            Configure <AbpAspNetCoreMvcOptions>(options =>
            {
                options.ConventionalControllers.Create(typeof(InBizModuleAppliction).Assembly);
            });
            Configure <RazorViewEngineOptions>(o =>
            {
                o.AreaViewLocationFormats.Add("/Modules/{2}/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
                o.AreaViewLocationFormats.Add("/Views/Shared/{0}.cshtml");
            });
            context.Services.Replace <IViewCompilerProvider, InBizViewCompilerProvider>();
        }