Example #1
0
        private IEnumerable <FileSystemItem> GetFileSystemEnumerable(IEnumerable <FileSystemItem> entities)
        {
            OnStart(null);
            var fileSystemItems  = entities.ToList();
            var filteredEntities = fileSystemItems.Where(_filter).ToList();

            foreach (var entity in fileSystemItems)
            {
                var isFile = entity.Type == FileSystemItemType.File;
                var args   = new SystemVisitorEventArgs
                {
                    IsStop    = false,
                    IsSkip    = false,
                    FoundItem = entity
                };
                if (isFile)
                {
                    OnFileFound(args);
                }
                else
                {
                    OnDirectoryFound(args);
                }
                if (!filteredEntities.Contains(entity))
                {
                    continue;
                }
                if (isFile)
                {
                    OnFilteredFileFound(args);
                }
                else
                {
                    OnFilteredDirectoryFound(args);
                }
                if (_isStop)
                {
                    yield break;
                }
                if (!_isSkip)
                {
                    yield return(entity);
                }
            }

            OnFinish(null);
        }
Example #2
0
 protected virtual void OnFilteredDirectoryFound(SystemVisitorEventArgs e)
 {
     FilteredDirectoryFound?.Invoke(this, e);
     _isStop = e.IsStop;
     _isSkip = e.IsSkip;
 }
Example #3
0
 protected virtual void OnDirectoryFound(SystemVisitorEventArgs e) => DirectoryFound?.Invoke(this, e);
Example #4
0
 protected virtual void OnFileFound(SystemVisitorEventArgs e) => FileFound?.Invoke(this, e);
Example #5
0
 protected virtual void OnFinish(SystemVisitorEventArgs e) => Finish?.Invoke(this, e);
Example #6
0
 protected virtual void OnStart(SystemVisitorEventArgs e) => Start?.Invoke(this, e);