public IServiceCollection CreateBuilder(IServiceCollection services) { _bootstrapper = new InternalBootstrapper(_startupModuleType, services, _context.Configuration, _optionsAction); _bootstrapper.Properties["HostingEnvironment"] = _context.HostingEnvironment; services.AddSingleton(_bootstrapper); return(services); }
/// <summary> /// /// </summary> /// <param name="builder"></param> /// <param name="startupModuleType"></param> /// <param name="optionsAction"></param> /// <returns></returns> public static IBootstrapper AddBootstrapper(this IHostBuilder builder, Type startupModuleType, Action <BootstrapperCreationOptions> optionsAction) { InternalBootstrapper bootstrapper = null; builder.ConfigureServices((context, services) => { bootstrapper = new InternalBootstrapper(startupModuleType, services, context.Configuration, optionsAction); bootstrapper.Properties["HostingEnvironment"] = context.HostingEnvironment; services.AddSingleton(bootstrapper); }); builder.UseServiceProviderFactory(new DynamicProxyServiceProviderFactory()); return(bootstrapper); }
protected IntegratedTest() { var services = CreateServiceCollection(); BeforeAddBootstrapper(services); var bootstrapper = new InternalBootstrapper(typeof(TStartupModule), services, null, SetBootstrapperCreationOptions); Bootstrapper = bootstrapper; AfterAddBootstrapper(services); RootServiceProvider = CreateServiceProvider(services); TestServiceScope = RootServiceProvider.CreateScope(); bootstrapper.SetServiceProvider(TestServiceScope.ServiceProvider); bootstrapper.Initialize(); }
/// <summary> /// Constructor /// </summary> protected Manager() { ConcurrentBag <Assembly> LoadedAssemblies = LoadAssemblies(); List <Type> LoadedTypes = GetTypes(ref LoadedAssemblies); List <Type> Bootstrappers = LoadedTypes.Where(x => x.GetInterfaces().Contains(typeof(IBootstrapper)) && x.IsClass && !x.IsAbstract && !x.ContainsGenericParameters && !x.Namespace.StartsWith("UTILITIES", StringComparison.OrdinalIgnoreCase)) .ToList(); if (Bootstrappers.Count == 0) { Bootstrappers.Add(typeof(DefaultBootstrapper)); } InternalBootstrapper = (IBootstrapper)Activator.CreateInstance(Bootstrappers[0], LoadedAssemblies, LoadedTypes); InternalBootstrapper.RegisterAll <IModule>(); foreach (IModule Module in InternalBootstrapper.ResolveAll <IModule>().OrderBy(x => x.Order)) { Module.Load(InternalBootstrapper); } }
public override void ConfigureServices(IServiceCollection services) { _bootstrapper = new InternalBootstrapper(_startuModuleType, services, _context.Configuration, _optionsAction); _bootstrapper.Properties["HostingEnvironment"] = _context.HostingEnvironment; services.AddSingleton(_bootstrapper); }