Skip to content

Commit

Permalink
more override appbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Jan 2, 2022
1 parent 95e6fd3 commit 3929156
Showing 1 changed file with 52 additions and 14 deletions.
66 changes: 52 additions & 14 deletions src/ConsoleAppFramework/ConsoleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HostBuilderContext, ConsoleAppOptions>? configureOptions)
{
return builder
Expand Down Expand Up @@ -78,38 +72,82 @@ IHost IHostBuilder.Build()
return builder.Build();
}

public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate)
IHostBuilder IHostBuilder.ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate)
{
return builder.ConfigureAppConfiguration(configureDelegate);
}

public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate)
IHostBuilder IHostBuilder.ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate)
{
return builder.ConfigureContainer(configureDelegate);
}

public IHostBuilder ConfigureHostConfiguration(Action<IConfigurationBuilder> configureDelegate)
IHostBuilder IHostBuilder.ConfigureHostConfiguration(Action<IConfigurationBuilder> configureDelegate)
{
return builder.ConfigureHostConfiguration(configureDelegate);
}

public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate)
IHostBuilder IHostBuilder.ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate)
{
return builder.ConfigureServices(configureDelegate);
}

public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory)
where TContainerBuilder : notnull
IHostBuilder IHostBuilder.UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory)
{
return builder.UseServiceProviderFactory(factory);
}

public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory)
where TContainerBuilder : notnull
IHostBuilder IHostBuilder.UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> 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<HostBuilderContext, IConfigurationBuilder> configureDelegate)
{
builder.ConfigureAppConfiguration(configureDelegate);
return this;
}

public ConsoleAppBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate)
{
builder.ConfigureContainer(configureDelegate);
return this;
}

public ConsoleAppBuilder ConfigureHostConfiguration(Action<IConfigurationBuilder> configureDelegate)
{
builder.ConfigureHostConfiguration(configureDelegate);
return this;
}

public ConsoleAppBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate)
{
builder.ConfigureServices(configureDelegate);
return this;
}

public ConsoleAppBuilder UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory)
where TContainerBuilder : notnull
{
builder.UseServiceProviderFactory(factory);
return this;
}

public ConsoleAppBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory)
where TContainerBuilder : notnull
{
builder.UseServiceProviderFactory(factory);
return this;
}

// Override Configure methods(Microsoft.Extensions.Hosting.HostingHostBuilderExtensions) tor return ConsoleAppBuilder

public ConsoleAppBuilder ConfigureLogging(Action<ILoggingBuilder> configureLogging)
Expand Down

0 comments on commit 3929156

Please sign in to comment.