Rename service add method
This commit is contained in:
parent
27167ace1b
commit
c13f4ddda1
@ -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 =>
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ public class TestServiceCollection
|
||||
public void CreateProvider()
|
||||
{
|
||||
var collection = new ServiceCollection();
|
||||
collection.AddModifiers();
|
||||
collection.AddProductParsers();
|
||||
ServiceProvider = collection.BuildServiceProvider();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user