Пример #1
0
        private async Task DownloadFilesAsync(Uri parentUri, HtmlDocument document, IConstraint constraint)
        {
            IEnumerable <string> links = document.GetAllLinksExceptTagALinks();
            var tasks = new List <Task>();

            foreach (string link in links)
            {
                if (!FilterLink(link))
                {
                    continue;
                }

                Uri uri = CreateUri(parentUri, link);
                if (!_visitedUris.Contains(uri) && constraint.IsSourceLinkPermissible(uri))
                {
                    _visitedUris.Add(uri);
                    tasks.Add(GetSourceFileAndDownloadAsync(uri));
                }
            }

            await Task.WhenAll(tasks);
        }