0
0

Rename service add method
All checks were successful
Test and release / test (push) Successful in 3m1s
Test and release / release-image (push) Successful in 3m40s

This commit is contained in:
Serghei Cebotari 2024-02-09 16:48:42 +03:00
parent 27167ace1b
commit c13f4ddda1
3 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ builder.Services.AddIdentity<IdentityUser, IdentityRole>()
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
.AddScoped<IProductTypePredicter, ProductTypePredicter>();
builder.Services.AddModifiers();
builder.Services.AddProductParsers();
builder.Services.AddControllers();
builder.Services.AddSwaggerGen(options =>
{

View File

@ -11,7 +11,7 @@ public class TestServiceCollection
public void CreateProvider()
{
var collection = new ServiceCollection();
collection.AddModifiers();
collection.AddProductParsers();
ServiceProvider = collection.BuildServiceProvider();
}

View File

@ -5,7 +5,7 @@ namespace RhSolutions.Parsers;
public static class ParsersRegistration
{
public static void AddModifiers(this IServiceCollection services)
public static void AddProductParsers(this IServiceCollection services)
{
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
@ -13,12 +13,12 @@ public static class ParsersRegistration
foreach (Type t in types)
{
string key = GetModifierKey(t);
string key = GetParserKey(t);
services.AddKeyedTransient(typeof(IProductParser), key, t);
}
}
private static string GetModifierKey(Type t)
private static string GetParserKey(Type t)
{
return t.GetCustomAttribute<ParserKey>()?.Value ?? string.Empty;
}