protected override bool Process(IInteraction parameters) { bool success = true; // FileSystemInfo[] infos = rootDirectory.GetFileSystemInfos ("*", SearchOption.AllDirectories); IEnumerable <FileSystemInfo> infos = rootDirectory.EnumerateFileSystemInfos("*", SearchOption.AllDirectories); IEnumerator <FileSystemInfo> infoEnumerator = infos.GetEnumerator(); while (infoEnumerator.MoveNext()) { try { FileSystemInfo info = infoEnumerator.Current; if (info is FileInfo) { success &= FileFound.TryProcess(new FileInteraction(info, this.RootPath, parameters)); } else if (info is DirectoryInfo) { success &= DirectoryFound.TryProcess(new DirectoryInteraction(info, this.RootPath, parameters)); } } catch (Exception ex) { Secretary.Report(5, "Inclusion of new file failed; ", ex.Message); } } return(success); }
protected override bool Process(IInteraction parameters) { string fullPath = ""; bool success = true; while (Changes.Count > 0) { fullPath = Changes.Dequeue(); if (Directory.Exists(fullPath)) { success &= DirectoryFound.TryProcess(new DirectoryInteraction(new DirectoryInfo(fullPath), RootPath, parameters)); } else if (File.Exists(fullPath)) { success &= FileFound.TryProcess(new FileInteraction(new FileInfo(fullPath), RootPath, parameters)); } else { success &= Gone.TryProcess(new FSInteraction(new FileInfo(fullPath), RootPath, parameters)); } } return(success); }