нужны разные ftp клиенты это превратится в следующее?
public class FtpClient : IFtpClient
{
private readonly FtpOptions _options = null!;
public FtpClient(FtpOptions options) =>_options = options;
}
public class AnotherFtpClient : IFtpClient
{
private readonly FtpOptions _options = null!;
public FtpClient(FtpOptions options) =>_options = options;
}
public class YetAnotherFtpClient : IFtpClient
{
private readonly FtpOptions _options = null!;
public FtpClient(FtpOptions options) =>_options = options;
}
public class Client1 : IClient1
{
private readonly IFtpClient _options = null!;
public Client1(IFtpClient options) =>_options = options;
}
public class Client2 : IClient2
{
private readonly IFtpClient _options = null!;
public Client2(IFtpClient options) =>_options = options;
}
public class Client3 : IClient3
{
private readonly IFtpClient _options = null!;
public Client3(IFtpClient options) =>_options = options;
}
services.AddTransient<IFtpClient, FtpClient>();
services.AddTransient<IFtpClient, AnotherFtpClient>();
services.AddTransient<IFtpClient, YetAnotherFtpClient>();
services.AddTransient<IClient1>(c => new Client1(c.GetRequiredService<FtpClient>()));
services.AddTransient<IClient2>(c => new Client2(c.GetRequiredService<AnotherFtpClient>()));
services.AddTransient<IClient3>(c => new Client3(c.GetRequiredService<YetAnotherFtpClient>()));
если у вас 3 разных фтп клиента, то да
Обсуждают сегодня