Skip to content

Commit

Permalink
fix: Module Services should use IContainerRegistry.TryRegisterSingleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jul 30, 2024
1 parent 422b7f9 commit 01a4940
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Maui/Prism.Maui/PrismAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public static PrismAppBuilder ConfigureModuleCatalog(this PrismAppBuilder builde
{
if (!s_didRegisterModules)
{
var services = builder.MauiBuilder.Services;
services.AddSingleton<IModuleCatalog, ModuleCatalog>();
services.AddSingleton<IModuleManager, ModuleManager>();
services.AddSingleton<IModuleInitializer, ModuleInitializer>();
builder.RegisterTypes(container =>
{
container.TryRegisterSingleton<IModuleCatalog, ModuleCatalog>();
container.TryRegisterSingleton<IModuleManager, ModuleManager>();
container.TryRegisterSingleton<IModuleInitializer, ModuleInitializer>();
});
}

s_didRegisterModules = true;
Expand Down

0 comments on commit 01a4940

Please sign in to comment.