예제 #1
0
        private List <UrlCrawlingResult> AccessToVisitedUrls(AccessType accessType, UrlCrawlingResult addingElement = null, int startElem = 0)
        {
            lock (this)
            {
                if (_visitedUrls == null)
                {
                    _visitedUrls = new List <UrlCrawlingResult>();
                }
                switch (accessType)
                {
                case AccessType.Read:
                    if (startElem >= _visitedUrls.Count)
                    {
                        return(new List <UrlCrawlingResult>());
                    }
                    var localResult = new List <UrlCrawlingResult>();
                    for (var i = startElem; i < _visitedUrls.Count; i++)
                    {
                        localResult.Add(_visitedUrls[i]);
                    }
                    return(localResult);

                case AccessType.Write:
                    if (addingElement != null)
                    {
                        _visitedUrls.Add(addingElement);
                    }
                    return(null);

                default:
                    return(null);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Safely adding result to list of results
 /// </summary>
 private void AddToVisitedUrls(UrlCrawlingResult ucResult)
 {
     AccessToVisitedUrls(AccessType.Write, ucResult);
 }