Exemplo n.º 1
0
        public virtual void BootstrapHost(BootstrapModuleHostCommand <TModule> command)
        {
            if (command.Host != null)
            {
                return;
            }

            BootstrapContext = command.BootstrapContext;

            var builder = CreateHostBuilder();

            ApplyConfiguration(builder);
            builder.ConfigureServices((ctx, services) =>
            {
                // ReSharper disable once ConvertToUsingDeclaration
                using (var tempServiceProvider = services.BuildServiceProvider())
                {
                    ConfigureServices(ctx, services, tempServiceProvider);
                }
            });


            command.Options.ConfigureBuilderAction?.Invoke(builder);
            command.Host          = builder.Build();
            command.ModuleContext = CreateModuleContext(command.Host.Services);
        }
Exemplo n.º 2
0
 public IModuleContext <TModule> CreateModuleContext(IModuleBootstrapContext <TModule> bootstrapContext, IServiceProvider moduleServices)
 {
     return(CreateModuleContextInternal(bootstrapContext.Module,
                                        moduleServices,
                                        bootstrapContext.ModulesHostServices,
                                        bootstrapContext.Advanced.FrameworkServices));
 }
Exemplo n.º 3
0
 internal ModulesHostBuilderContext(HostBuilderContext hostBuilderContext, IModuleBootstrapContext <TModule> bootstrapContext)
 {
     _bootstrapContext  = bootstrapContext;
     HostBuilderContext = hostBuilderContext
                          ?? bootstrapContext.Advanced.FrameworkServices.GetRequiredService <HostBuilderContext>();
     Advanced = new AdvancedModuleContext(_bootstrapContext.Advanced.FrameworkServices,
                                          bootstrapContext.Advanced.HostServices,
                                          _bootstrapContext);
 }
Exemplo n.º 4
0
 public static IModuleContext ToModuleContext <TModule>(
     this IModuleBootstrapContext <TModule> bootstrapContext, IServiceProvider moduleServices) where TModule : class
 {
     return(new ModuleContext <TModule>(
                bootstrapContext.Module,
                moduleServices,
                bootstrapContext.ModulesHostServices,
                bootstrapContext.Advanced.FrameworkServices,
                bootstrapContext));
 }
Exemplo n.º 5
0
        public IModuleContext <TModule> CreateModuleContext(IModuleBootstrapContext <TModule> bootstrapContext, IServiceProvider moduleServices)
        {
            if (!(bootstrapContext is ISimpleInjectorModuleContext containerContext))
            {
                throw new InvalidOperationException($"{nameof(bootstrapContext)} contains no SimpleInjector container. This is not expected here. Actual type: {bootstrapContext.GetType()}");
            }

            return(new ModuleContextWithContainer <TModule>(containerContext.Container,
                                                            bootstrapContext.Module,
                                                            moduleServices,
                                                            bootstrapContext.ModulesHostServices,
                                                            bootstrapContext.Advanced.FrameworkServices));
        }
Exemplo n.º 6
0
 public static IModulesHostBuilderContext ToModuleHostBuilderContext <TModule>(
     this IModuleBootstrapContext <TModule> bootstrapContext, HostBuilderContext hostBuilderContext = null) where TModule : class
 {
     return(new ModulesHostBuilderContext <TModule>(hostBuilderContext, bootstrapContext));
 }