public ServiceConfigrationSection GetServiceConfig(string serviceName) { var serviceSection = _conf.GetSection(serviceName); if (serviceSection == null) { return(null); } ServiceConfigrationSection config = new ServiceConfigrationSection(); serviceSection.Bind(config); return(config); }
public async Task <MangaInfo> LoadMangaInfoAsync(MangaInfo mangaInfo) { mangaInfo.CheckArgumentNull(nameof(mangaInfo)); string mangaUrl = mangaInfo.Href; mangaUrl.CheckArgumentEmptyOrNull(nameof(mangaUrl)); Uri mangaUri = new Uri(mangaUrl); MangaSource mangaSource = GetSourceByUrl(mangaUri); mangaInfo.Source = mangaSource ?? throw new ArgumentException("Wrong url domain"); string sourceName = mangaSource.Name; ServiceConfigrationSection config = _configHelper.GetServiceConfig(sourceName); if (config == null) { throw new ArgumentException($"No handler for source {sourceName}"); } _htmlDocumentLoader.Cookies = config.Cookies; HtmlDocument document = await _htmlDocumentLoader.GetHtmlDoc(mangaInfo.Href); return(FillMangaInfo(mangaInfo, mangaSource, document)); }