public ModuleInstance( ModuleDescriptor moduleDescriptor, string moduleInstanceId, PathString pathBase, IServiceCollection sharedServices, IServiceProvider appServiceProvider, ModuleInstanceOptions options) { ModuleDescriptor = moduleDescriptor; ModuleInstanceId = moduleInstanceId; PathBase = pathBase; AddSharedServices(sharedServices, appServiceProvider); ModuleServiceCollection.Add(moduleDescriptor.ModuleServiceCollection); ModuleServiceCollection.AddSingleton <ModuleInstanceIdProvider>(new ModuleInstanceIdProvider(moduleInstanceId)); ModuleServiceCollection.AddSingleton <IRootServiceProvider>(new RootServiceProvider(appServiceProvider)); if (options != null) { foreach (var configureServices in options.ConfigureServices) { configureServices(ModuleServiceCollection); } } ModuleServices = ModuleServiceCollection.BuildServiceProvider(); }
IModuleStartup GetModuleStartup() { if (typeof(IModuleStartup).GetTypeInfo().IsAssignableFrom(ModuleStartupType)) { ModuleServiceCollection.AddSingleton(typeof(IModuleStartup), ModuleStartupType); } else { ModuleServiceCollection.AddSingleton <IModuleStartup>(sp => { var hostingEnvironment = sp.GetRequiredService <IHostingEnvironment>(); return(new ConventionBasedModuleStartup( ModuleStartupLoader.LoadMethods(sp, ModuleStartupType, hostingEnvironment.EnvironmentName))); }); } var moduleHostingServiceProvider = ModuleServiceCollection.BuildServiceProvider(); return(moduleHostingServiceProvider.GetRequiredService <IModuleStartup>()); }
void AddHostingServices() { ModuleServiceCollection.Add(_hostingServices); ModuleServiceCollection.AddSingleton(ModuleHostingEnvironment); }