From 3929156309ea299e7a53147852d0e0e016a76f34 Mon Sep 17 00:00:00 2001 From: neuecc Date: Sun, 2 Jan 2022 12:40:29 +0900 Subject: [PATCH] more override appbuilder --- src/ConsoleAppFramework/ConsoleAppBuilder.cs | 66 +++++++++++++++----- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/ConsoleAppFramework/ConsoleAppBuilder.cs b/src/ConsoleAppFramework/ConsoleAppBuilder.cs index 687cd4e..4b9c157 100644 --- a/src/ConsoleAppFramework/ConsoleAppBuilder.cs +++ b/src/ConsoleAppFramework/ConsoleAppBuilder.cs @@ -41,12 +41,6 @@ internal ConsoleAppBuilder(string[] args, IHostBuilder hostBuilder, ConsoleAppOp this.builder = AddConsoleAppFramework(hostBuilder, args, options, (_, __) => { }); } - public ConsoleApp Build() - { - var host = builder.Build(); - return new ConsoleApp(host); - } - IHostBuilder AddConsoleAppFramework(IHostBuilder builder, string[] args, ConsoleAppOptions options, Action? configureOptions) { return builder @@ -78,38 +72,82 @@ IHost IHostBuilder.Build() return builder.Build(); } - public IHostBuilder ConfigureAppConfiguration(Action configureDelegate) + IHostBuilder IHostBuilder.ConfigureAppConfiguration(Action configureDelegate) { return builder.ConfigureAppConfiguration(configureDelegate); } - public IHostBuilder ConfigureContainer(Action configureDelegate) + IHostBuilder IHostBuilder.ConfigureContainer(Action configureDelegate) { return builder.ConfigureContainer(configureDelegate); } - public IHostBuilder ConfigureHostConfiguration(Action configureDelegate) + IHostBuilder IHostBuilder.ConfigureHostConfiguration(Action configureDelegate) { return builder.ConfigureHostConfiguration(configureDelegate); } - public IHostBuilder ConfigureServices(Action configureDelegate) + IHostBuilder IHostBuilder.ConfigureServices(Action configureDelegate) { return builder.ConfigureServices(configureDelegate); } - public IHostBuilder UseServiceProviderFactory(IServiceProviderFactory factory) - where TContainerBuilder : notnull + IHostBuilder IHostBuilder.UseServiceProviderFactory(IServiceProviderFactory factory) { return builder.UseServiceProviderFactory(factory); } - public IHostBuilder UseServiceProviderFactory(Func> factory) - where TContainerBuilder : notnull + IHostBuilder IHostBuilder.UseServiceProviderFactory(Func> factory) { return builder.UseServiceProviderFactory(factory); } + // override implementations that returns ConsoleAppBuilder + + public ConsoleApp Build() + { + var host = builder.Build(); + return new ConsoleApp(host); + } + + public ConsoleAppBuilder ConfigureAppConfiguration(Action configureDelegate) + { + builder.ConfigureAppConfiguration(configureDelegate); + return this; + } + + public ConsoleAppBuilder ConfigureContainer(Action configureDelegate) + { + builder.ConfigureContainer(configureDelegate); + return this; + } + + public ConsoleAppBuilder ConfigureHostConfiguration(Action configureDelegate) + { + builder.ConfigureHostConfiguration(configureDelegate); + return this; + } + + public ConsoleAppBuilder ConfigureServices(Action configureDelegate) + { + builder.ConfigureServices(configureDelegate); + return this; + } + + public ConsoleAppBuilder UseServiceProviderFactory(IServiceProviderFactory factory) + where TContainerBuilder : notnull + { + builder.UseServiceProviderFactory(factory); + return this; + } + + public ConsoleAppBuilder UseServiceProviderFactory(Func> factory) + where TContainerBuilder : notnull + { + builder.UseServiceProviderFactory(factory); + return this; + } + // Override Configure methods(Microsoft.Extensions.Hosting.HostingHostBuilderExtensions) tor return ConsoleAppBuilder public ConsoleAppBuilder ConfigureLogging(Action configureLogging)