예제 #1
0
        public async Task <CrossStitchPageContent> Parse(string lastSavedId)
        {
            var hasSavedId     = int.TryParse(lastSavedId, out var lastId);
            var models         = new List <CrossStitchPatternModel>();
            var currentPageNum = 1;
            var hasMorePages   = hasSavedId;

            do
            {
                var uri = new Uri($"https://www.stitch.su/patterns?favch=4&lim={ItemsPerPage}&page={currentPageNum}");
                using (var content = await DownloadContent(uri))
                {
                    var pageModels = content.SelectPatterns(uri);
                    if (hasSavedId)
                    {
                        var minIdOnPage = pageModels.Min(m => m.PatternId.Id);
                        hasMorePages = minIdOnPage > lastId;
                        currentPageNum++;
                    }
                    models.AddRange(pageModels);
                }
            }while (hasMorePages);
            var pageContent = new CrossStitchPageContent()
            {
                Patterns = models
            };

            return(pageContent);
        }
예제 #2
0
        public async Task <CrossStitchPageContent> Parse()
        {
            var patternModels  = new List <CrossStitchPatternModel>();
            var kitModels      = new List <WishlistKitModel>();
            var currentPageNum = 1;
            int?totalPages     = null;

            do
            {
                var uri = new Uri($"https://www.stitch.su/users/wishlist/Lamya/page{currentPageNum}");
                using (var content = await DownloadContent(uri))
                {
                    totalPages ??= content.CalculatePagesCount();
                    patternModels.AddRange(content.SelectPatterns(uri));
                    kitModels.AddRange(content.SelectKits(uri));
                }
            } while (++currentPageNum <= totalPages.Value);
            var pageContent = new CrossStitchPageContent
            {
                Patterns = patternModels,
                Kits     = kitModels
            };

            return(pageContent);
        }
예제 #3
0
        public async Task <CrossStitchPageContent> Parse(int pageId)
        {
            var models = new List <CrossStitchPatternModel>();
            var uri    = new Uri($"https://www.stitch.su/patterns?favch=4&lim={ItemsPerPage}&page={pageId}");

            using (var content = await DownloadContent(uri))
            {
                var pageModels = content.SelectPatterns(uri);
                models.AddRange(pageModels);
            }
            var pageContent = new CrossStitchPageContent()
            {
                Patterns = models
            };

            return(pageContent);
        }