/// <summary> /// Configure the bootstrapper to use Autofac as IoC. /// </summary> /// <param name="bootstrapper">Instance of bootstrapper.</param> /// <param name="containerBuilderConfiguration">Configuration to apply on freshly created container builder.</param> /// <param name="excludedAutoRegisterTypeDLLs">DLLs name to exclude from auto-configuration into IoC /// (IAutoRegisterType will be ineffective).</param> public static Bootstrapper UseAutofacAsIoC(this Bootstrapper bootstrapper, Action <ContainerBuilder> containerBuilderConfiguration, params string[] excludedAutoRegisterTypeDLLs) { var service = new AutofacBootstrappService { BootstrappAction = (_) => ConfigureAutofacContainer(bootstrapper, containerBuilderConfiguration, excludedAutoRegisterTypeDLLs) }; bootstrapper.AddService(service); return(bootstrapper); }
/// <summary> /// Configure the bootstrapper to use Autofac as IoC. /// </summary> /// <param name="bootstrapper">Instance of bootstrapper.</param> /// <param name="containerBuilder">Autofac container builder that has been configured according to app..</param> /// <param name="excludedAutoRegisterTypeDLLs">DLLs name to exclude from auto-configuration into IoC /// (IAutoRegisterType will be ineffective).</param> public static Bootstrapper UseAutofacAsIoC(this Bootstrapper bootstrapper, ContainerBuilder containerBuilder, params string[] excludedAutoRegisterTypeDLLs) { if (containerBuilder == null) { throw new ArgumentNullException(nameof(containerBuilder)); } var service = new AutofacBootstrappService { BootstrappAction = (_) => CreateConfigWithContainer(bootstrapper, containerBuilder, excludedAutoRegisterTypeDLLs) }; bootstrapper.AddService(service); return(bootstrapper); }
/// <summary> /// Configure the bootstrapper to use Autofac as IoC, by using /// a defining a scope to be used a root scope for CQELight. /// BEWARE : The scope should be kept alive in order to allow the system to work, /// because if it's disposed, you will not be able to use CQELight IoC. /// </summary> /// <param name="bootstrapper">Instance of bootstrapper.</param> /// <param name="scope">Scope instance</param> /// <param name="excludedAutoRegisterTypeDLLs">DLLs name to exclude from auto-configuration into IoC /// (IAutoRegisterType will be ineffective).</param> /// <returns>Configured bootstrapper</returns> public static Bootstrapper UseAutofacAsIoC(this Bootstrapper bootstrapper, ILifetimeScope scope, params string[] excludedAutoRegisterTypeDLLs) { var service = new AutofacBootstrappService { BootstrappAction = (_) => { var childScope = scope.BeginLifetimeScope(cb => AddRegistrationsToContainerBuilder(bootstrapper, cb, excludedAutoRegisterTypeDLLs)); InitDIManagerAndCreateScopeFactory(childScope); } }; bootstrapper.AddService(service); return(bootstrapper); }
/// <summary> /// Configure the bootstrapper to use Autofac as IoC. /// </summary> /// <param name="bootstrapper">Instance of boostrapper.</param> /// <param name="containerBuilderConfiguration">Configuration to apply on freshly created container builder.</param> /// <param name="excludedAutoRegisterTypeDLLs">DLLs name to exclude from auto-configuration into IoC /// (IAutoRegisterType will be ineffective).</param> public static Bootstrapper UseAutofacAsIoC(this Bootstrapper bootstrapper, Action <ContainerBuilder> containerBuilderConfiguration, params string[] excludedAutoRegisterTypeDLLs) { var service = new AutofacBootstrappService { BootstrappAction = (ctx) => { var containerBuilder = new ContainerBuilder(); containerBuilderConfiguration?.Invoke(containerBuilder); CreateConfigWithContainer(bootstrapper, containerBuilder, excludedAutoRegisterTypeDLLs); } }; bootstrapper.AddService(service); return(bootstrapper); }