Skip to content

Commit

Permalink
fix(app): register only enabled modules
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Dec 6, 2023
1 parent 608cd19 commit 83d2bca
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Sitko.Core.App/SitkoCoreApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,21 @@ private void RegisterModule<TModule, TModuleOptions>(

var registration =
new ApplicationModuleRegistration<TModule, TModuleOptions>(instance, configureOptions, optionsKey);

if (typeof(TModule).IsAssignableTo(typeof(IHostBuilderModule)))
if (registration.IsEnabled(BootApplicationContext))
{
ConfigureHostBuilder<TModule, TModuleOptions>(registration);
}
if (typeof(TModule).IsAssignableTo(typeof(IHostBuilderModule)))
{
ConfigureHostBuilder<TModule, TModuleOptions>(registration);
}

registration.ConfigureAppConfiguration(BootApplicationContext, Builder.Configuration);
registration.ConfigureOptions(BootApplicationContext, Builder.Services);
registration.ConfigureServices(BootApplicationContext, Builder.Services);
registration.ConfigureAppConfiguration(BootApplicationContext, Builder.Configuration);
registration.ConfigureOptions(BootApplicationContext, Builder.Services);
registration.ConfigureServices(BootApplicationContext, Builder.Services);

if (typeof(TModule).IsAssignableTo(typeof(IHostBuilderModule)))
{
registration.PostConfigureHostBuilder(BootApplicationContext, Builder);
if (typeof(TModule).IsAssignableTo(typeof(IHostBuilderModule)))
{
registration.PostConfigureHostBuilder(BootApplicationContext, Builder);
}
}

moduleRegistrations.Add(registration);
Expand Down

0 comments on commit 83d2bca

Please sign in to comment.