diff --git a/src/BitzArt.Blazor.Cookies.Client/Extensions/AddBlazorCookiesExtension.cs b/src/BitzArt.Blazor.Cookies.Client/Extensions/AddBlazorCookiesExtension.cs index ad1baa2..99cb088 100644 --- a/src/BitzArt.Blazor.Cookies.Client/Extensions/AddBlazorCookiesExtension.cs +++ b/src/BitzArt.Blazor.Cookies.Client/Extensions/AddBlazorCookiesExtension.cs @@ -5,9 +5,17 @@ namespace BitzArt.Blazor.Cookies; public static class AddBlazorCookiesExtension { - public static WebAssemblyHostBuilder AddBlazorCookies(this WebAssemblyHostBuilder builder) + public static WebAssemblyHostBuilder AddBlazorCookies(this WebAssemblyHostBuilder builder, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - builder.Services.AddScoped(); + builder.Services.AddBlazorCookiesClient(lifetime); + return builder; } + + private static IServiceCollection AddBlazorCookiesClient(this IServiceCollection services, ServiceLifetime lifetime) + { + services.Add(new ServiceDescriptor(typeof(ICookieService), typeof(BrowserCookieService), lifetime)); + + return services; + } }