public IEnumerable <VisitedFileSystemEntity> GetResultOfBypassingDirectories(string rootDirectoryPath)
        {
            if (string.IsNullOrEmpty(rootDirectoryPath) || rootDirectoryPath.IndexOfAny(Path.GetInvalidPathChars()) >= 0 || !Directory.Exists(rootDirectoryPath))
            {
                throw new ArgumentException($"Passed rootDirectoryPath {rootDirectoryPath} is not valid.");
            }

            OnStartBypassing();

            foreach (var visitedEntity in _fileSystemEntitiesProvider.GetFileSystemEntities(rootDirectoryPath))
            {
                var args = new FileSystemVisitorEventArgs();

                OnEntityFound(visitedEntity, args);

                if (_bypassingFilter(visitedEntity))
                {
                    OnFilteredEntityFound(visitedEntity, args);

                    if (args.ShouldStopSearch)
                    {
                        break;
                    }

                    if (args.ShouldExcludeResult)
                    {
                        continue;
                    }

                    yield return(visitedEntity);
                }
            }

            OnFinishBypassing();
        }
 private void OnFilteredEntityFound(VisitedFileSystemEntity fileSystemEntity, FileSystemVisitorEventArgs args)
 {
     if (fileSystemEntity.EntityType == VisitedFileSystemEntityType.Directory)
     {
         OnFilteredDirectoryFound(args);
     }
     else
     {
         OnFilteredFileFound(args);
     }
 }
        private void OnFilteredFileFound(FileSystemVisitorEventArgs args)
        {
            var handler = FilteredFileFound;

            handler?.Invoke(this, args);
        }
        private void OnDirectoryFound(FileSystemVisitorEventArgs args)
        {
            var handler = DirectoryFound;

            handler?.Invoke(this, args);
        }