From 780bc01891e8ac961516ab37d1a0564575ad374f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Hlav=C3=A1=C4=8D?= Date: Thu, 10 Aug 2023 07:59:58 +0200 Subject: [PATCH] refactor Web Crawler example - use constructor DI instead of Service.Resolve --- .../Search/WebCrawlerService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Kentico.Xperience.Lucene.Sample/Search/WebCrawlerService.cs b/src/Kentico.Xperience.Lucene.Sample/Search/WebCrawlerService.cs index 0a80786..f155cd4 100644 --- a/src/Kentico.Xperience.Lucene.Sample/Search/WebCrawlerService.cs +++ b/src/Kentico.Xperience.Lucene.Sample/Search/WebCrawlerService.cs @@ -10,14 +10,16 @@ public class WebCrawlerService private readonly HttpClient httpClient; private readonly IPageUrlRetriever urlRetriever; private readonly IEventLogService eventLogService; + private readonly IAppSettingsService appSettingsService; - public WebCrawlerService(HttpClient httpClient, IPageUrlRetriever urlRetriever, IEventLogService eventLogService) + public WebCrawlerService(HttpClient httpClient, IPageUrlRetriever urlRetriever, IEventLogService eventLogService, IAppSettingsService appSettingsService) { + this.appSettingsService = appSettingsService; this.httpClient = httpClient; // configure the client inside constructor if needed (add custom headers etc.) this.httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, "SearchCrawler"); // get crawler base url from settings or site configuration, make sure that WebCrawlerBaseUrl is correct - string baseUrl = ValidationHelper.GetString(Service.Resolve()["WebCrawlerBaseUrl"], DocumentURLProvider.GetDomainUrl("DancingGoatCore")); + string baseUrl = ValidationHelper.GetString(appSettingsService["WebCrawlerBaseUrl"], DocumentURLProvider.GetDomainUrl("DancingGoatCore")); this.httpClient.BaseAddress = new Uri(baseUrl); this.urlRetriever = urlRetriever;