/// <summary> /// The constructor of <see cref="SynRequester"/>. /// <para>Initializes underlying <see cref="HttpClient"/> instances and others.</para> /// </summary> /// <param name="_httpClientHandler">The <see cref="HttpClientHandler"/> instance to use for the underlying <see cref="HttpClient"/> instance</param>. /// <param name="_logger">The <see cref="ILogger"/> instance to use for Logging inside the current instance of <see cref="SynRequester"/></param>. /// <param name="_delayBetweenRequests">Sets the delay between each request. (in seconds)</param> /// <param name="_delayBetweenFailedRequests">Sets the delay between each failed request. (in seconds)</param> public SynRequester(HttpClientHandler _httpClientHandler, ILogger _logger, int _delayBetweenRequests = 3, int _delayBetweenFailedRequests = 10) { ClientHandler = _httpClientHandler ?? new HttpClientHandler(); InstanceID = (Random.Next(10 + _httpClientHandler.GetHashCode() + _httpClientHandler.CookieContainer.GetHashCode()) ^ Random.Next(_logger != null ? 35 : 15) ^ _delayBetweenFailedRequests + _delayBetweenRequests).GetHashCode().ToString(); Logger = _logger ?? new Logger($"{nameof(SynRequester)}|{InstanceID}"); DELAY_BETWEEN_REQUESTS = _delayBetweenRequests; DELAY_BETWEEN_FAILED_REQUESTS = _delayBetweenFailedRequests; Cookies = ClientHandler.CookieContainer; Client = new HttpClient(ClientHandler, false); }