private void ProcessFilteredEntry(FileSystemInfoBase systemInfoBase, FilteredFileSystemInfoFound args) { var isDirectory = systemInfoBase.Attributes.HasFlag(FileAttributes.Directory); if (isDirectory) { FilteredDirectoryFound?.Invoke(systemInfoBase, args); } else { FilteredFileFound?.Invoke(systemInfoBase, args); } }
protected virtual void OnFilteredDirectoryFound(FilteredContentFindedEventArgs e) { if (ReferenceEquals(e, null)) { throw new ArgumentNullException(); } FilteredDirectoryFound?.Invoke(this, e); if (!_searchStopped) { _searchStopped = e.StopSearch; } _itemRemoved = e.RemoveItem; }
public FileSystemVisitor(string rootPath, Func <FileSystemInfo, bool> predicate) : this(rootPath) { _dirsAndFiles = _dirsAndFiles.Where(item => predicate(item)).ToList(); _dirsAndFiles.ForEach(item => { if ((item.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { FilteredDirectoryFound?.Invoke(this, new FilteredItemFoundEventArgs <DirectoryInfo>(item as DirectoryInfo)); } else { FilteredFileFound?.Invoke(this, new FilteredItemFoundEventArgs <FileInfo>(item as FileInfo)); } }); }
private FileSystemInfoCustomCollection <CustomFileItem> GetItemsRecursively(string directoryPath, FilterMask filterMask) { var directoryInfo = (CustomDirectoryInfo)customDirectoryInfoFactory.CreateInstance(directoryPath); var output = new FileSystemInfoCustomCollection <CustomFileItem>(); if (isFirstFilteredFileFound && filterMask.HasFlag(FilterMask.FirstOnly)) { return(output); } if (!filterMask.HasFlag(FilterMask.NoFolders)) { DirectoryFound?.Invoke(this, new ItemFoundArgs { Item = directoryInfo }); if (filterMask.HasFlag(FilterMask.IgnoreFilterFunction) || FileFilterDelegate.Invoke(directoryInfo)) { FilteredDirectoryFound?.Invoke(this, new ItemFoundArgs { Item = directoryInfo }); output.Add(directoryInfo); isFirstFilteredFileFound = true; if (isFirstFilteredFileFound && filterMask.HasFlag(FilterMask.FirstOnly)) { return(output); } } } var files = directoryInfo.GetFiles(); foreach (var file in files) { FileFound?.Invoke(this, new ItemFoundArgs { Item = file }); if (filterMask.HasFlag(FilterMask.IgnoreFilterFunction) || FileFilterDelegate.Invoke(file)) { FilteredFileFound?.Invoke(this, new ItemFoundArgs { Item = file }); output.Add(file); isFirstFilteredFileFound = true; if (isFirstFilteredFileFound && filterMask.HasFlag(FilterMask.FirstOnly)) { return(output); } } } var directories = directoryInfo.GetDirectories(); foreach (var directory in directories) { var result = GetItemsRecursively(directory.FullName, filterMask); foreach (var item in result) { output.Add(item); } } return(output); }
protected virtual void OnFilteredDirectoryFound(ItemFoundInfoEventArgs e) { FilteredDirectoryFound?.Invoke(this, e); }
protected virtual void OnFilteredDirectoryFound(SystemVisitorEventArgs e) { FilteredDirectoryFound?.Invoke(this, e); _isStop = e.IsStop; _isSkip = e.IsSkip; }
private void OnFilteredDirectoryFound(PathEventArgs args) { FilteredDirectoryFound?.Invoke(this, args); }
protected virtual void OnFilteredDirectoryFound(DirectoryEventArgs args) { FilteredDirectoryFound?.Invoke(this, args); }