Example #1
0
        public IEnumerable <string> OutputFolder(int choice)
        {
            string[] folders = null;
            Start?.Invoke("Start");
            try
            {
                folders = Directory.GetFiles(_path, _filter, SearchOption.AllDirectories);
            }
            catch (UnauthorizedAccessException)
            {
                Console.WriteLine("Access denieds");
            }

            if (folders != null)
            {
                if (choice == 1)
                {
                    filterFinded?.Invoke("With filtration");
                    for (int i = 0; i < folders.Length; i++)
                    {
                        yield return(folders[i]);
                    }
                }
                else
                {
                    Finded?.Invoke("No filtration");
                    for (int i = 0; i < folders.Length; i++)
                    {
                        yield return(folders[i]);
                    }
                }
            }
            Finish("Finish");
            yield break;
        }
Example #2
0
 public Parser(Uri uri, int depth, int maxCount, HttpClient client, IAnalyzer analyzer)
 {
     #region Проверки
     if (uri is null)
     {
         throw new ArgumentNullException("uri is null");
     }
     if (depth <= 1)
     {
         throw new ArgumentOutOfRangeException("depth must be greater than 1");
     }
     if (maxCount <= 1)
     {
         throw new ArgumentOutOfRangeException("maxCount must be greater than 1");
     }
     if (client is null)
     {
         throw new ArgumentNullException("client is null");
     }
     if (analyzer is null)
     {
         throw new ArgumentNullException("analyzer is null");
     }
     #endregion
     URI              = uri;
     Depth            = depth;
     MaxCount         = maxCount;
     Client           = client;
     Analyzer         = analyzer;
     Analyzer.Finded += s => Finded.Invoke(s);
 }
Example #3
0
        protected void OnFindedRaise(FindDataResultEventArgs arg)
        {
            if (arg == null)
            {
                throw new ArgumentNullException(nameof(arg));
            }

            Finded?.Invoke(this, arg);
        }
Example #4
0
        static void CheckQueue()
        {
            do
            {
                while (Finded.Any())
                {
                    Finded.TryDequeue(out var finish);
                    File.AppendAllText(@"D:\temp\txt\Finded.txt", finish + "\r\n");
                }
                while (Finished.Any())
                {
                    Finished.TryDequeue(out var finish);
                    File.AppendAllText(@"D:\temp\txt\Finished.txt", finish + "\r\n");
                }


                Task.Delay(1000);
            } while(true);
        }
Example #5
0
 protected void OnFindedRaise(string findText, object result)
 {
     Finded?.Invoke(this, new FindDataResultEventArgs(findText, result));
 }