public override async Task Execute(object parameter) { try { var selected = model.SelectedProxySettingModel; var address = new Uri(model.TestAddress); var setting = new ProxySetting(selected.SettingType) { Address = selected.Address, UserName = selected.UserName, Password = selected.Password }; var proxy = setting.GetProxy(); var client = SiteHttpClientFactory.Get(address, proxy, new CookieContainer()); var page = await client.GetPage(address).ConfigureAwait(true); if (page.HasContent) { Dialogs.ShowInfo("Проверка прокси", "Успешно."); } else { Dialogs.ShowInfo("Проверка прокси", "Не удалось получить страницу, проверьте настройки.\r\n" + page.Error); } } catch (Exception e) { Dialogs.ShowInfo("Проверка прокси", "Произошла ошибка. \r\n" + e.Message); } }
public async Task <ISiteHttpClient> GetCookieClient(bool withLogin) { var login = await LoginCache.Get(MangaGuid).ConfigureAwait(false); var mainUri = login.MainUri; var client = SiteHttpClientFactory.Get(mainUri, MangaSettingCache.Get(typeof(T)).Proxy, CookieContainer); await this.ConfigureCookieClient(client, login).ConfigureAwait(false); if (withLogin && !login.IsLogined(MangaGuid)) { await login.DoLogin(MangaGuid).ConfigureAwait(false); } return(client); }