Skip to content

Commit

Permalink
configure internal host (#36)
Browse files Browse the repository at this point in the history
* configure internal host
added method to ModulesHostBuilder to configure only the internal host

* added ConfigureInternalHost to interface
  • Loading branch information
fw2568 authored Sep 1, 2022
1 parent 128c676 commit af6eef2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/Hosuto.Abstractions/Modules/Hosting/IModuleHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ public interface IModulesHostBuilder: IHostBuilder
IModulesHostBuilder HostModule<TModule>(Action<IModuleHostingOptions> options = null) where TModule : class;
IModulesHostBuilder HostModule(Type moduleType, Action<IModuleHostingOptions> options = null);

/// <summary>
/// Direct access to the host builder used to build the internal host. This could be used
/// in special cases when you would like to apply configuration only to the internal host and not to the modules.
/// </summary>
/// <param name="configureDelegate">The delegate for configuring the <see cref="IHostBuilder"/> that will be used
/// to construct the internal host.</param>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
IModulesHostBuilder ConfigureInternalHost(Action<IHostBuilder> configureDelegate);

/// <summary>
/// Set up the configuration for the builder itself. This will be used to initialize the <see cref="IHostEnvironment"/>
/// for use later in the build process. This can be called multiple times and the results will be additive.
/// </summary>
/// <param name="configureDelegate">The delegate for configuring the <see cref="IConfigurationBuilder"/> that will be used
/// to construct the <see cref="IConfiguration"/> for the host.</param>
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
new IModulesHostBuilder ConfigureHostConfiguration(Action<IConfigurationBuilder> configureDelegate);

/// <summary>
Expand All @@ -27,15 +36,15 @@ public interface IModulesHostBuilder: IHostBuilder
/// </summary>
/// <param name="configureDelegate">The delegate for configuring the <see cref="IConfigurationBuilder"/> that will be used
/// to construct the <see cref="IConfiguration"/> for the application.</param>
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
new IModulesHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate);

/// <summary>
/// Adds services to the container. This can be called multiple times and the results will be additive.
/// </summary>
/// <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>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
new IModulesHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate);


Expand All @@ -44,7 +53,7 @@ public interface IModulesHostBuilder: IHostBuilder
/// </summary>
/// <param name="configureDelegate">The delegate for configuring the <see cref="IServiceCollection"/> that will be used
/// to construct the internal <see cref="IServiceProvider"/> used to configure the module builder.</param>
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
IModulesHostBuilder ConfigureFrameworkServices(Action<HostBuilderContext, IServiceCollection> configureDelegate);


Expand All @@ -54,7 +63,7 @@ public interface IModulesHostBuilder: IHostBuilder
/// </summary>
/// <typeparam name="TContainerBuilder">The type of builder.</typeparam>
/// <param name="factory">The factory to register.</param>
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
new IModulesHostBuilder UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory);

#if NETSTANDARD2_1
Expand All @@ -71,7 +80,7 @@ public interface IModulesHostBuilder: IHostBuilder
/// </summary>
/// <typeparam name="TContainerBuilder">The type of builder.</typeparam>
/// <param name="configureDelegate">The delegate which configures the builder.</param>
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
/// <returns>The same instance of the <see cref="IModulesHostBuilder"/> for chaining.</returns>
new IModulesHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate);


Expand Down
6 changes: 6 additions & 0 deletions src/Hosuto.Hosting/Modules/Hosting/ModulesHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public IModulesHostBuilder ConfigureHostConfiguration(
return this;
}

public IModulesHostBuilder ConfigureInternalHost(Action<IHostBuilder> configureDelegate)
{
configureDelegate(_innerBuilder);
return this;
}

public IModulesHostBuilder ConfigureFrameworkServices(Action<HostBuilderContext, IServiceCollection> configureDelegate)
{
_configureFrameworkActions.Add(configureDelegate ?? throw new ArgumentNullException(nameof(configureDelegate)));
Expand Down

0 comments on commit af6eef2

Please sign in to comment.