I have the following code in asp.net core 3.1 project :
IArticleService.cs
namespace API.Interfaces
{
public interface IArticleService
{
Task<ArticleDTO> GetArticleAsync(int articleId, int countryId, string userCookieId);
}
}
ArticleService.cs
namespace API.Services
{
public class ArticleService : IArticleService
{
private readonly IOptions<UrlsConfig> _urlConfig;
private readonly HttpClient _httpClient;
private readonly ILogger<ArticleService> _logger;
public ArticleService(HttpClient httpClient, IOptions<UrlsConfig> urlConfig, ILogger<ArticleService> logger)
{
_urlConfig = urlConfig;
_httpClient = httpClient;
_logger = logger;
}
public async Task<ArticleDTO> GetArticleAsync(int articleId, int countryId, string userCookieId)
{
throw new System.NotImplementedException();
}
}
}
ProjectServiceCollectionExtensions.cs
public static IServiceCollection AddHttpClientDependencies(this IServiceCollection services)
{
return services.AddHttpClient<IArticleService, ArticleService>();
}
Startup.cs
public virtual void ConfigureServices(IServiceCollection services) => services.AddHttpClientDependencies()
It is throwing an error :
Error CS0266 Cannot implicitly convert type 'Microsoft.Extensions.DependencyInjection.IHttpClientBuilder' to 'Microsoft.Extensions.DependencyInjection.IServiceCollection'. An explicit conversion exists (are you missing a cast?)
Can anyone help me here with some guidance to fix this issue?