示例#1
0
        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);
            }
        }
示例#2
0
        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;
        }
示例#3
0
        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));
                }
            });
        }
示例#4
0
        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);
 }
示例#6
0
 protected virtual void OnFilteredDirectoryFound(SystemVisitorEventArgs e)
 {
     FilteredDirectoryFound?.Invoke(this, e);
     _isStop = e.IsStop;
     _isSkip = e.IsSkip;
 }
示例#7
0
 private void OnFilteredDirectoryFound(PathEventArgs args)
 {
     FilteredDirectoryFound?.Invoke(this, args);
 }
示例#8
0
 protected virtual void OnFilteredDirectoryFound(DirectoryEventArgs args)
 {
     FilteredDirectoryFound?.Invoke(this, args);
 }