public void Scan(string url) { CurrentPage = new BLPage(url); while (CurrentPage.NextPageUrl != null) { ImageUrls.AddRange(CurrentPage.Images.Where(img => ImageUrls.All(im => im != img.Url)).Select(im => im.Url)); CurrentPage = new BLPage(CurrentPage.NextPageUrl); } }
public void ReplaceOrAddPage(BLPage page) { if (page.CurrentPageNumber != -1) { LoadedPages.RemoveAll(lp => lp.CurrentPageNumber == page.CurrentPageNumber); LoadedPages.Add(RemoveQuotesAndRepeats(page)); } Debug.WriteLine("Invalid page added"); }
public BLPage GetBLPageByPageNumber(int pageNumber) { if (LoadedPages.Any(lp => lp.CurrentPageNumber == pageNumber)) { return(LoadedPages.First(lp => lp.CurrentPageNumber == pageNumber)); } string pageUrl = OpeningPostUrl; if (OpeningPostUrl.Contains('/')) { pageUrl = OpeningPostUrl.Substring(0, OpeningPostUrl.LastIndexOf('/')); } var pageUrlIdentity = OpeningPostUrl.Split('/').Last().Split('?')[0]; var bPage = new BLPage(string.Format(pageByUrlFormat, pageUrl, pageUrlIdentity, pageNumber)); LoadedPages.Add(RemoveQuotesAndRepeats(bPage)); return(bPage); }
public BLPage RemoveQuotesAndRepeats(BLPage newPage) { newPage.Images.RemoveAll(im => LoadedPages.Any(lp => lp.Images.Any(lpi => lpi.Url == im.Url))); return(newPage); }