Files
components/LiteCharms.Features.MidrandBooks/Extensions/Shop.cs
T
Khwezi Mngoma 9296f0331e
continuous-integration/drone/pr Build is passing
Refactored registration of Features service from Scoped to Transient
2026-06-13 10:06:54 +02:00

25 lines
898 B
C#

using LiteCharms.Features.Abstractions;
using LiteCharms.Features.MidrandBooks.Abstractions;
namespace LiteCharms.Features.MidrandBooks.Extensions;
public static class Shop
{
public static IServiceCollection AddShopServices(this IServiceCollection services)
{
var serviceType = typeof(IService);
var sharedImplementations = typeof(IFeatures).Assembly.GetTypes()
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
foreach (var sharedImplementation in sharedImplementations) services.AddTransient(sharedImplementation);
var coreImplementations = typeof(IMidrandBooks).Assembly.GetTypes()
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
foreach (var coreImplementation in coreImplementations) services.AddScoped(coreImplementation);
return services;
}
}