public IEnumerable <ModuleDescriptor> GetModuleDescriptors(ModuleLoadContext context) { var env = context.HostingEnvironment; return(ModuleLoaderHelpers.GetModuleStartupTypes(env.ApplicationName, env.EnvironmentName) .Select(moduleStartupType => new ModuleDescriptor(moduleStartupType, context.HostingServices, env, context.ModuleOptions))); }
public ModuleManager(IServiceCollection services, ModulesOptions options) { _options = options; _hostingServices = CreateHostingServices(services); var moduleLoadContext = new ModuleLoadContext() { HostingEnvironment = services.GetServiceFromCollection <IHostingEnvironment>(), HostingServices = _hostingServices, ModuleOptions = options.ModuleOptions }; var moduleDescriptors = _options.ModuleLoaders .SelectMany(moduleLoader => moduleLoader.GetModuleDescriptors(moduleLoadContext)); foreach (var moduleDescriptor in moduleDescriptors) { var moduleStartup = moduleDescriptor.ModuleServiceCollection.BuildServiceProvider().GetRequiredService <IModuleStartup>(); moduleStartup.ConfigureSharedServices(SharedServices); _modulesDescriptors[moduleDescriptor.Name] = moduleDescriptor; } }