I am working on refactoring some code. I discovered that one of my team colleagues created an interface like this:
public interface IConfiguration<T>
{
string Url { get; }
string Password { get; }
}
This T parameter seems to be redundant, but then I discovered that it is actually used in dependency injection configuration (it is ASP.NET core 2.2 application), like this:
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services
.AddSingleton<IConfiguration<Person>, PersonConfiguration>()
.AddSingleton<IConfiguration<Product>, ProductConfiguration>()
.AddSingleton<IConfiguration<Order>, OrderConfiguration>()
}
I don't know why but, I have strong distaste about this approach. Could any one suggest some more clean design (conforming to the SOLID principles) to this?
Aucun commentaire:
Enregistrer un commentaire