30 lines
978 B
C#
30 lines
978 B
C#
namespace ChatServerSpace.Services
|
|
{
|
|
public class ChatServiceFactory : IChatServiceFactory
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public ChatServiceFactory(IServiceProvider serviceProvider, IConfiguration configuration)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public IChatService CreateChatService()
|
|
{
|
|
// Determine qual implementação usar com base nas configurações
|
|
var useDirectHttpClient = _configuration.GetValue<string>("ChatServer:UseServer");
|
|
|
|
if (useDirectHttpClient== "DeepInfra")
|
|
{
|
|
return _serviceProvider.GetRequiredService<DeepInfraChatService>();
|
|
}
|
|
else
|
|
{
|
|
return _serviceProvider.GetRequiredService<ServerSpaceChatService>();
|
|
}
|
|
}
|
|
}
|
|
}
|