@@ -6,16 +6,26 @@ namespace SemanticKernelPooling;
66public static class SemanticKernelPoolingServiceExtensions
77{
88 /// <summary>
9- /// Registers the Semantic Kernel Pooling services and all configured AI service providers.
9+ /// Registers the Semantic Kernel Pooling services and all configured AI service providers
10+ /// with a specified lifetime (Singleton, Scoped, or Transient). Singleton by default
1011 /// </summary>
1112 /// <param name="services">The service collection to add the services to.</param>
13+ /// <param name="lifetime">
14+ /// Specifies the service lifetime for the Semantic Kernel Pooling services.
15+ /// </param>
1216 /// <returns>The updated service collection.</returns>
13- // ReSharper disable once UnusedMember.Global
14- public static IServiceCollection UseSemanticKernelPooling ( this IServiceCollection services )
17+ /// <example>
18+ /// This example demonstrates how to use the method to register services with different lifetimes:
19+ /// <code>
20+ /// services.UseSemanticKernelPooling(ServiceLifetime.Singleton); // Register as Singleton
21+ /// services.UseSemanticKernelPooling(ServiceLifetime.Scoped); // Register as Scoped
22+ /// services.UseSemanticKernelPooling(ServiceLifetime.Transient); // Register as Transient
23+ /// </code>
24+ /// </example>
25+ public static IServiceCollection UseSemanticKernelPooling ( this IServiceCollection services , ServiceLifetime lifetime = ServiceLifetime . Singleton )
1526 {
16- // Register the KernelPoolManager as a singleton
17- services . AddSingleton < IKernelPoolManager , KernelPoolManager > ( ) ;
18- services . AddSingleton < IKernelPoolFactoryRegistrar , KernelPoolFactoryRegistrar > ( ) ;
27+ services . Add ( new ( typeof ( IKernelPoolManager ) , typeof ( KernelPoolManager ) , lifetime ) ) ;
28+ services . Add ( new ( typeof ( IKernelPoolFactoryRegistrar ) , typeof ( KernelPoolFactoryRegistrar ) , lifetime ) ) ;
1929
2030 return services ;
2131 }
0 commit comments