/// <summary> /// Try to Get The Favicon From the homepage Server /// Use Google tool, So please ensure your computer unblocked Google /// </summary> /// public static async Task TryUpdateIconSource(this FeedViewModel feedViewModel, string HomePageUrl) { if (feedViewModel.IconSrc.ToString() != string.Empty) { return; } if (HomePageUrl == string.Empty) { return; } //一般这个不会发生 var feedId = feedViewModel.Id ?? -1; int numberOfAttempts = 2; bool success = false; // 尝试下载2次 do { success = await WebIconDownloadTool.DownLoadIconFrom_IconUri(HomePageUrl, feedId.ToString()); } while (!success && numberOfAttempts-- > 0); // 如果成功,更新IconSrc, iconsrc为下载的图片文件的文件名,否则IconSrc还会是默认的那个图标路径 if (success) { feedViewModel.IconSrc = feedId.ToString() + ".png"; await SQLiteService.UpdateFeedInfoAsync(feedViewModel.AbstractInfo()); } }
public async void getIconTest() { await WebIconDownloadTool.DownLoadIconFrom_WebUri("https://blogs.msdn.microsoft.com/", "111"); }