protected void OnObjectFiltered(FilteredObjectEventArgs arg) { if (arg == null) { throw new ArgumentNullException(nameof(arg)); } Console.WriteLine($"Filtered {arg.FilteredObject.GetFileSystemType()} {arg.FilteredObject.FullName}"); this.ObjectFiltered?.Invoke(this, arg); _cancelSearch = arg.CancelSearch; switch (arg.FilteredObject.GetFileSystemType()) { case "-F-": _exceptFiles = arg.ExeptObject; break; case "-D-": _exceptDirectories = arg.ExeptObject; break; default: throw new ArgumentException($"Unkown object type recived: {arg.FilteredObject.GetFileSystemType()}"); } if (_cancelSearch) { Console.WriteLine($"Search is canceled!"); } if (_exceptDirectories) { Console.WriteLine($"Directories are excepted from search!"); } if (_exceptFiles) { Console.WriteLine($"Files are excepted from search!"); } }
private void ProcessFilter(object sender, FilteredObjectEventArgs arg) { if (_cancelSearch.Invoke(arg.FilteredObject.FullName)) { arg.CancelSearch = true; } if (arg.FilteredObject is DirectoryObject) { if (_exceptDirectory.Invoke(arg.FilteredObject.FullName)) { arg.ExeptObject = true; } } else { if (_exceptFile.Invoke(arg.FilteredObject.FullName)) { arg.ExeptObject = true; } } }