public IEnumerable <FileSystemInfoBase> GetDirectoryInnerEntities(DirectoryInfoBase entryDirectoryInfo) { bool isCancelled = false; foreach (var entryDirectoryEntity in entryDirectoryInfo.GetFileSystemInfos()) { if (isCancelled) { break; } EntityFoundArgs entityFoundArgs = new EntityFoundArgs() { EntityInfo = entryDirectoryEntity }; if (entryDirectoryEntity is DirectoryInfoBase) { entityFoundArgs.Message = "Directory found"; OnDirectoryFound(entityFoundArgs); if ((IsFilterAlgorithmPassed == null || IsFilterAlgorithmPassed(entryDirectoryEntity)) && !entityFoundArgs.IsExcluded) { entityFoundArgs.Message = "Filtered directory found"; OnFilteredDirectoryFound(entityFoundArgs); yield return(entryDirectoryEntity); } } else { entityFoundArgs.Message = "File found"; OnFileFound(entityFoundArgs); if ((IsFilterAlgorithmPassed == null || IsFilterAlgorithmPassed(entryDirectoryEntity)) && !entityFoundArgs.IsExcluded) { entityFoundArgs.Message = "Filtered file found"; OnFilteredFileFound(entityFoundArgs); yield return(entryDirectoryEntity); } } if (entityFoundArgs.IsCancelled) { isCancelled = true; } } if (!isCancelled) { foreach (var entryDirectoryEntity in entryDirectoryInfo.GetDirectories()) { foreach (var entity in GetDirectoryInnerEntities(entryDirectoryEntity)) { yield return(entity); } } } }
protected virtual void OnFilteredDirectoryFound(EntityFoundArgs args) { var temporary = FilterDirectoryFound; temporary?.Invoke(this, args); }