public static IHostBuilder UseMicronetes(this IHostBuilder builder)
 {
     return(builder.ConfigureServices(services => services.AddMicronetes()));
 }
Exemplo n.º 2
0
 public static MultipleServerHostBuilder AsMultipleServerHostBuilder(this IHostBuilder hostBulder)
 {
     return(new MultipleServerHostBuilder(hostBulder));
 }
Exemplo n.º 3
0
        public static ISuperSocketHostBuilder <TReceivePackage> AsSuperSocketHostBuilder <TReceivePackage, TPipelineFilter>(this IHostBuilder hostBuilder)
            where TPipelineFilter : IPipelineFilter <TReceivePackage>, new()
        {
            if (hostBuilder is ISuperSocketHostBuilder <TReceivePackage> ssHostBuilder)
            {
                return(ssHostBuilder);
            }

            return((new SuperSocketHostBuilder <TReceivePackage>(hostBuilder))
                   .UsePipelineFilter <TPipelineFilter>());
        }
Exemplo n.º 4
0
 public void ConfigureHost(IHostBuilder host)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add a <see cref="DbContext"/> and configure them in the next constructing pipeline.
 /// </summary>
 /// <typeparam name="TContext">The required <see cref="DbContext"/>.</typeparam>
 /// <param name="builder">The <see cref="IHostBuilder"/></param>
 /// <param name="configures">The configure delegate</param>
 /// <returns>The <see cref="IHostBuilder"/></returns>
 public static IHostBuilder AddDatabase <TContext>(this IHostBuilder builder, Action <DbContextOptionsBuilder> configures) where TContext : DbContext
 {
     return(builder.AddDatabase <TContext>((_, b) => configures(b)));
 }
Exemplo n.º 6
0
 public static IHostBuilder ConfigureDiscordBot(
     this IHostBuilder hostBuilder,
     Action <IBotApplicationBuilder> configure = null)
 {
     return(ConfigureDiscordBot(hostBuilder, true, configure));
 }
 public static Task RunAsServiceAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default)
 {
     return(hostBuilder.UseServiceBaseLifetime().Build().RunAsync(cancellationToken));
 }
Exemplo n.º 8
0
 public WorkerHostBuilder(IHostBuilder hostBuilder)
 {
     this.HostBuilder = hostBuilder;
 }
 public static IHostBuilder ConfigureDefaultTestWebScriptHost(this IHostBuilder builder, Action <ScriptApplicationHostOptions> configure = null, bool runStartupHostedServices = false)
 {
     return(builder.ConfigureDefaultTestWebScriptHost(null, configure, runStartupHostedServices));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Use this override to customize the services registered with the IHostBuilder.
 ///
 /// It is recommended not to call ConfigureWebHostDefaults to configure the IWebHostBuilder inside this method.
 /// Instead customize the IWebHostBuilder in the Init(IWebHostBuilder) overload.
 /// </summary>
 /// <param name="builder"></param>
 protected override void Init(IHostBuilder builder)
 {
 }
Exemplo n.º 11
0
 protected override IHost CreateHost(IHostBuilder builder)
 {
     builder.UseServiceProviderFactory(new CustomServiceProviderFactory());
     return(base.CreateHost(builder));
 }
 protected override IHost CreateHost(IHostBuilder builder) => _createHost(builder);
Exemplo n.º 13
0
 public static void ConfigureHost(IHostBuilder builder) =>
 builder
 .ConfigureAppConfiguration(builder =>
                            builder.AddConfiguration(Configuration.Base))
 .UseSerilog();
Exemplo n.º 14
0
 public static IHostBuilder ConfigureDefaultTestHost(this IHostBuilder builder, params Type[] types)
 {
     return(builder.ConfigureDefaultTestHost(b => { }, types));
 }
Exemplo n.º 15
0
 /// <inheritdoc/>
 protected override IHost CreateHost(IHostBuilder builder)
 {
     builder.UseAutofac();
     return(base.CreateHost(builder));
 }
 /// <summary>
 /// Listens for Unity.Application.quit <see cref="UnityEngine.Application"/> to start the shutdown process.
 /// This will unblock extensions like RunAsync and WaitForShutdownAsync.
 /// </summary>
 /// <param name="hostBuilder">The <see cref="IHostBuilder" /> to configure.</param>
 /// <param name="configureOptions">The delegate for configuring the <see cref="UnityLifetime"/>.</param>
 /// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
 public static IHostBuilder UseUnityLifetime(this IHostBuilder hostBuilder, Action <UnityLifeTimeOptions> configureOptions) =>
 hostBuilder.ConfigureServices((context, collection) =>
 {
     collection.AddSingleton <IHostLifetime, UnityLifetime>();
     collection.Configure(configureOptions);
 });
Exemplo n.º 17
0
 internal static bool IsDiscordBotConfigures(this IHostBuilder hostBuilder)
 {
     return(hostBuilder.Properties.TryGetValue(DiscordBotProperty, out var value) && Equals(value, true));
 }
 /// <summary>
 /// Listens for Unity.Application.quit <see cref="UnityEngine.Application"/> to start the shutdown process.
 /// This will unblock extensions like RunAsync and WaitForShutdownAsync.
 /// </summary>
 /// <param name="hostBuilder">The <see cref="IHostBuilder" /> to configure.</param>
 /// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
 public static IHostBuilder UseUnityLifetime(this IHostBuilder hostBuilder) =>
 hostBuilder.ConfigureServices((context, collection) => collection.AddSingleton <IHostLifetime, UnityLifetime>());
Exemplo n.º 19
0
        /// <summary>
        /// 泛型主机注入
        /// </summary>
        /// <param name="hostBuilder">泛型主机注入构建器</param>
        /// <param name="autoRegisterBackgroundService">是否自动注册 BackgroundService</param>
        /// <returns>IWebHostBuilder</returns>
        public static IHostBuilder Inject(this IHostBuilder hostBuilder, bool autoRegisterBackgroundService = true)
        {
            InternalApp.ConfigureApplication(hostBuilder, autoRegisterBackgroundService);

            return(hostBuilder);
        }
Exemplo n.º 20
0
 internal static IHostBuilder ConfigureModules(this IHostBuilder builder)
 => builder.ConfigureAppConfiguration((ctx, cfg) =>
 public static IHostBuilder UseServiceBaseLifetime(this IHostBuilder hostBuilder)
 {
     return(hostBuilder.ConfigureServices((hostContext, services) => services.AddSingleton <IHostLifetime, ServiceBaseLifetime>()));
 }
 /// <summary>
 /// Configure Configuration with embedded appsettings.json
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static IHostBuilder ConfigureEmbeddedConfiguration(this IHostBuilder builder, string[] args)
 => ConfigureEmbeddedConfiguration(builder, args, Assembly.GetEntryAssembly(), AppContext.BaseDirectory);
Exemplo n.º 23
0
        public static void Main(string[] args)
        {
            IHostBuilder builder = CreateHostBuilder(args);

            builder.Build().Run();
        }
Exemplo n.º 24
0
 public static IHostBuilder AddWordsAPIClient(this IHostBuilder hostBuilder, Action <WordsAPIOptions> configureOptions = null) =>
 hostBuilder.ConfigureServices(s => s.AddWordsAPIClient(ob => ob.Configure(configureOptions)));
Exemplo n.º 25
0
        XafApplication IDesignTimeApplicationFactory.Create()
        {
            IHostBuilder hostBuilder = CreateHostBuilder(Array.Empty <string>());

            return(DesignTimeApplicationFactoryHelper.Create(hostBuilder));
        }
Exemplo n.º 26
0
 /// <summary>
 ///  Must be call after Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults()
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static IHostBuilder ConfigureSilkierQuartzHost(this IHostBuilder builder)
 {
     _quartzHostedServiceIsAdded = true;
     return(builder.ConfigureServices(services => services.AddHostedService <QuartzHostedService>()));
 }
Exemplo n.º 27
0
        public static ISuperSocketHostBuilder <TReceivePackage> AsSuperSocketHostBuilder <TReceivePackage>(this IHostBuilder hostBuilder)
        {
            if (hostBuilder is ISuperSocketHostBuilder <TReceivePackage> ssHostBuilder)
            {
                return(ssHostBuilder);
            }

            return(new SuperSocketHostBuilder <TReceivePackage>(hostBuilder));
        }
Exemplo n.º 28
0
 public static IHostBuilder ConfigureQuartzHost(this IHostBuilder builder) => builder.ConfigureSilkierQuartzHost();
Exemplo n.º 29
0
        public static IServer BuildAsServer(this IHostBuilder hostBuilder)
        {
            var host = hostBuilder.Build();

            return(host.AsServer());
        }
Exemplo n.º 30
0
 public static IHostBuilder ConfigureCooperLogging(this IHostBuilder builder, string applicationName)
 => builder.ConfigureLogging((ctx, logging) =>