public static IModulesHostBuilder ConfigureWebHostDefaults(this IModulesHostBuilder builder, Action <Microsoft.AspNetCore.Hosting.IWebHostBuilder> configure) { return(builder.UseAspNetCoreWithDefaults((module, webHostBuilder) => { configure(webHostBuilder); })); }
public static Task RunModule(this IModulesHostBuilder hostBuilder, Type moduleType, Action <IModuleHostingOptions> options = null) { hostBuilder.HostModule(moduleType, options); return(hostBuilder.Build().RunAsync()); }
public static IModulesHostBuilder UseAspNetCoreWithDefaults(this IModulesHostBuilder builder, Action <IWebModule, Microsoft.AspNetCore.Hosting.IWebHostBuilder> configure = null) { builder.ConfigureFrameworkServices((ctx, services) => { services .TryAddTransient <IWebModuleWebHostBuilderInitializer, WebModuleWebHostBuilderInitializerWithDefaults >(); }); return(UseAspNetCore(builder, configure)); }
public static IModulesHostBuilder UseSimpleInjector(this IModulesHostBuilder hostBuilder) { hostBuilder.ConfigureFrameworkServices((ctx, services) => { services.AddTransient(typeof(IModuleContextFactory <>), typeof(ModuleContextFactory <>)); services.AddTransient(typeof(IModuleServicesFilter), typeof(AddSimpleInjectorModuleServicesFilter)); services.AddTransient(typeof(IBootstrapHostFilter <>), typeof(BootstrapHostFilter <>)); }); return(hostBuilder); }
/// <summary> /// Adds services to the container. This can be called multiple times and the results will be additive. /// </summary> /// <param name="hostBuilder"></param> /// <param name="configureDelegate">The delegate for configuring the <see cref="IServiceCollection"/> that will be used /// to construct the <see cref="IServiceProvider"/>.</param> /// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns> public static IModulesHostBuilder ConfigureServices( this IModulesHostBuilder hostBuilder, Action <IModulesHostBuilderContext, IServiceCollection> configureDelegate) { hostBuilder.ConfigureFrameworkServices((ctx, services) => { services.AddTransient <IModuleServicesFilter>(sp => new DelegateModuleServicesFilter(configureDelegate)); }); return(hostBuilder); }
public static IModulesHostBuilder ConfigureAspNetCore(this IModulesHostBuilder builder, Action <IWebModule, Microsoft.AspNetCore.Hosting.IWebHostBuilder> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } builder.ConfigureFrameworkServices((ctx, services) => { services.TryAddTransient <IWebModuleWebHostBuilderFilter>(sp => new DelegateWebModuleWebHostBuilderFilter(configure)); }); return(builder); }
public static IModulesHostBuilder UseAspNetCore(this IModulesHostBuilder builder, Func <Microsoft.AspNetCore.Hosting.IWebHostBuilder> webHostBuilder, Action <IWebModule, Microsoft.AspNetCore.Hosting.IWebHostBuilder> configure = null) { if (webHostBuilder == null) { throw new ArgumentNullException(nameof(webHostBuilder)); } builder.ConfigureFrameworkServices((ctx, services) => { services.AddTransient(typeof(IBootstrapHostFilter <>), typeof(WebModuleBootstrapHostFilter <>)); services.TryAddTransient <IWebModuleWebHostBuilderFactory>(sp => new DelegateWebHostBuilderFactory(webHostBuilder)); }); return(ConfigureAspNetCore(builder, configure)); }
public static IModulesHostBuilder UseAspNetCore(this IModulesHostBuilder builder, Action <IWebModule, Microsoft.AspNetCore.Hosting.IWebHostBuilder> configure = null) { builder.ConfigureFrameworkServices((ctx, services) => { services.AddTransient(typeof(IBootstrapHostFilter <>), typeof(WebModuleBootstrapHostFilter <>)); services.TryAddTransient <IWebModuleWebHostBuilderInitializer, WebModuleWebHostBuilderInitializer>(); if (configure != null) { services.AddTransient <IWebModuleWebHostBuilderFilter>(sp => new DelegateWebModuleWebHostBuilderFilter(configure)); } }); return(builder); }
// ReSharper disable once UnusedMethodReturnValue.Global public static IModulesHostBuilder UseSimpleInjector(this IModulesHostBuilder hostBuilder, Container container, bool enableModuleContainer = true) { if (container.Options.DefaultScopedLifestyle == null) { container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); } hostBuilder.ConfigureFrameworkServices((ctx, services) => { services.AddSingleton(container); services.AddTransient <IModuleHostServiceProviderFactory, ServiceProviderFactory>(); }); return(!enableModuleContainer ? hostBuilder : UseSimpleInjector(hostBuilder)); }
public static IModulesHostBuilder AddIdentityModule(this IModulesHostBuilder builder, Container container) { builder.HostModule <IdentityModule>(); builder.ConfigureFrameworkServices((ctx, services) => { services.AddTransient <IConfigureContainerFilter <IdentityModule>, IdentityModuleFilters>(); services.AddTransient <IModuleServicesFilter <IdentityModule>, IdentityModuleFilters>(); }); container.RegisterSingleton <IConfigReaderService <ClientConfigModel>, ClientConfigReaderService>(); container.RegisterSingleton <IConfigWriterService <ClientConfigModel>, ClientConfigWriterService>(); container.Register <IDbContextConfigurer <ConfigurationDbContext>, InMemoryConfigurationStoreContextConfigurer>(); return(builder); }
public static Task RunModule <TModule>(this IModulesHostBuilder hostBuilder, Action <IModuleHostingOptions> options = null) where TModule : class { return(RunModule(hostBuilder, typeof(TModule), options)); }
public static IModulesHostBuilder UseServiceCollection(this IModulesHostBuilder hostBuilder, IServiceCollection services) { hostBuilder.UseServiceProviderFactory(new ServiceCollectionServiceProviderFactory(services)); return(hostBuilder); }