Ejemplo n.º 1
0
 static void foundReached(object sender, FoundEventArgs e)
 {
     //Console.WriteLine("{0} was found. It {1} the filtration.", e.Name,
     //e.IsFiltrationPassed ? "passed" : "didn't pass");
     if (!e.Name.EndsWith("LICENSE.txt"))
     {
         e.ExcludeEntry = true;
     }
 }
 public IEnumerable <string> DirSearch(string sDir, bool isFirstTimeCalled = true)
 {
     if (isFirstTimeCalled)
     {
         Start?.Invoke(this, null);
     }
     if (Directory.Exists(sDir))
     {
         foreach (string file in Directory.GetFiles(sDir))
         {
             var args = new FoundEventArgs();
             args.Name = $"File {file}";
             args.IsFiltrationPassed = predicate(file);
             OnFileFoundReached(args);
             if (args.IsFiltrationPassed && !args.ExcludeEntry)
             {
                 yield return(file);
             }
         }
         foreach (string directory in Directory.GetDirectories(sDir))
         {
             var args = new FoundEventArgs();
             args.Name = $"Directory {directory}";
             args.IsFiltrationPassed = predicate(directory);
             OnDitectoryFoundReached(args);
             if (args.IsFiltrationPassed)
             {
                 yield return(directory);
             }
             foreach (var dirSearch in DirSearch(directory, false))
             {
                 yield return(dirSearch);
             }
         }
     }
     if (isFirstTimeCalled)
     {
         Finish?.Invoke(this, null);
     }
 }
 protected void OnDitectoryFoundReached(FoundEventArgs e)
 {
     DitectoryFound?.Invoke(this, e);
 }
 protected void OnFileFoundReached(FoundEventArgs e)
 {
     FileFound?.Invoke(this, e);
 }