Exemplo n.º 1
0
 protected virtual void ConfigureServices(HostBuilderContext hostBuilderContext, IServiceCollection services, IServiceProvider serviceProvider)
 {
     Filters.BuildFilterPipeline(
         BootstrapContext.Advanced.FrameworkServices.GetServices <IModuleServicesFilter>()
         .Append(GenericModuleHostBuilderContextAdapter <IServiceCollection> .Create(typeof(IModuleServicesFilter <>)))
         , (ctx, s) =>
     {
         ModuleMethodInvoker.CallOptionalMethod(BootstrapContext.ToModuleContext(serviceProvider), "ConfigureServices", serviceProvider, s);
     })
         (BootstrapContext.ToModuleHostBuilderContext(hostBuilderContext), services);
 }
Exemplo n.º 2
0
        public Action <IModulesHostBuilderContext, IServiceCollection> Invoke(Action <IModulesHostBuilderContext, IServiceCollection> next) =>
        (context, services) =>
        {
            next(context, services);

            if (context.Advanced.RootContext is ISimpleInjectorModuleContext containerContext)
            {
                services.AddSimpleInjector(containerContext.Container, options =>
                {
                    Filters.BuildFilterPipeline(
                        context.Advanced.FrameworkServices.GetServices <IAddSimpleInjectorFilter>()
                        .Append(GenericModuleHostBuilderContextAdapter <SimpleInjectorAddOptions> .Create(typeof(IAddSimpleInjectorFilter <>))),
                        (ctx, o) =>
                    {
                        ModuleMethodInvoker.CallOptionalMethod(containerContext, "AddSimpleInjector", o);
                    })(context, options);
                });
            }
        };