Example #1
0
        public void Build(HashSet <string> urls)
        {
            progressCounter = 0;
            foreach (string url in urls)
            {
                if (!url.StartsWith("http"))
                {
                    continue;
                }

                string hostname = Crawler.Hostname(url);

                bool isInserted = false;
                foreach (var folder in map)
                {
                    if (folder.Name == hostname)
                    {
                        if (hostname != url)
                        {
                            folder.Insert(url.Substring(hostname.Length + 1));
                        }

                        isInserted = true;
                        break;
                    }
                }

                if (!isInserted)
                {
                    var folder = new Folder(hostname);
                    if (hostname != url)
                    {
                        folder.Insert(url.Substring(hostname.Length + 1));
                    }
                    map.Add(folder);
                }
                if (++progressCounter % 100 == 0)
                {
                    OnProgress?.Invoke(progressCounter / (double)(urls.Count) * 100.0);
                }
            }
        }