Refactored database registration to allow postgres to use internal representations for afster performance
This commit is contained in:
@@ -4,19 +4,15 @@ namespace LiteCharms.Features.MidrandBooks.Extensions;
|
||||
|
||||
public static class Shop
|
||||
{
|
||||
public static IServiceCollection AddShopServices(this IServiceCollection services, Assembly assembly, ServiceLifetime serviceLifetime)
|
||||
public static IServiceCollection AddShopServices(this IServiceCollection services)
|
||||
{
|
||||
var serviceType = typeof(IService);
|
||||
|
||||
var implementations = assembly.GetTypes()
|
||||
var implementations = Assembly.GetExecutingAssembly().GetTypes()
|
||||
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
|
||||
|
||||
foreach (var implementation in implementations)
|
||||
{
|
||||
var descriptor = new ServiceDescriptor(serviceType, implementation, serviceLifetime);
|
||||
|
||||
services.Add(descriptor);
|
||||
}
|
||||
foreach (var implementation in implementations)
|
||||
services.AddScoped(implementation);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user