diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/IServiceCollectionExtensions.cs b/src/BlazorUI/Bit.BlazorUI.Extras/IServiceCollectionExtensions.cs
index 2a476d7020..108d64b637 100644
--- a/src/BlazorUI/Bit.BlazorUI.Extras/IServiceCollectionExtensions.cs
+++ b/src/BlazorUI/Bit.BlazorUI.Extras/IServiceCollectionExtensions.cs
@@ -5,9 +5,15 @@ namespace Bit.BlazorUI;
public static class IServiceCollectionExtensions
{
- public static IServiceCollection AddBitBlazorUIExtrasServices(this IServiceCollection services, bool singleton = false)
+ ///
+ /// Registers required services of the Extras package of the BitBlazorUI components.
+ ///
+ ///
+ /// Tries to register the services as singleton, but only for the services can be singleton (e.g. the services that do not use IJSRuntime).
+ ///
+ public static IServiceCollection AddBitBlazorUIExtrasServices(this IServiceCollection services, bool trySingleton = false)
{
- if (singleton)
+ if (trySingleton)
{
services.TryAddSingleton();
}
diff --git a/src/BlazorUI/Bit.BlazorUI/Utils/IServiceCollectionExtensions.cs b/src/BlazorUI/Bit.BlazorUI/Extensions/IServiceCollectionExtensions.cs
similarity index 54%
rename from src/BlazorUI/Bit.BlazorUI/Utils/IServiceCollectionExtensions.cs
rename to src/BlazorUI/Bit.BlazorUI/Extensions/IServiceCollectionExtensions.cs
index 02ddf71eb9..c2eade972f 100644
--- a/src/BlazorUI/Bit.BlazorUI/Utils/IServiceCollectionExtensions.cs
+++ b/src/BlazorUI/Bit.BlazorUI/Extensions/IServiceCollectionExtensions.cs
@@ -5,16 +5,9 @@ namespace Bit.BlazorUI;
public static class IServiceCollectionExtensions
{
- public static IServiceCollection AddBitBlazorUIServices(this IServiceCollection services, bool singleton = false)
+ public static IServiceCollection AddBitBlazorUIServices(this IServiceCollection services)
{
- if (singleton)
- {
- services.TryAddSingleton();
- }
- else
- {
- services.TryAddScoped();
- }
+ services.TryAddScoped();
return services;
}
diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Extensions/IServiceCollectionExtensions.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Extensions/IServiceCollectionExtensions.cs
index 2f3c89c0ec..e0e28c4ada 100644
--- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Extensions/IServiceCollectionExtensions.cs
+++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Extensions/IServiceCollectionExtensions.cs
@@ -23,8 +23,8 @@ public static IServiceCollection AddClientSharedServices(this IServiceCollection
services.TryAddTransient();
services.TryAddScoped();
- services.AddBitBlazorUIServices(singleton: AppRenderMode.IsBlazorHybrid);
- services.AddBitBlazorUIExtrasServices(singleton: AppRenderMode.IsBlazorHybrid);
+ services.AddBitBlazorUIServices();
+ services.AddBitBlazorUIExtrasServices(trySingleton: AppRenderMode.IsBlazorHybrid);
services.AddSharedServices();
return services;