public IDisposable RegisterNotification(Path path, string filter = "*", bool includeSubdirectories = false, Action <File> created = null, Action <File> modified = null, Action <File> deleted = null, Action <File> renamed = null) { if (created == null && modified == null && renamed == null && deleted == null) { throw new ArgumentException("One event type (created, modified, renamed or deleted) must be specified."); } WatcherChangeTypes watcher = 0; if (created != null) { watcher |= WatcherChangeTypes.Created; } if (modified != null) { watcher |= WatcherChangeTypes.Changed; } if (renamed != null) { watcher |= WatcherChangeTypes.Renamed; } if (deleted != null) { watcher |= WatcherChangeTypes.Deleted; } var id = new FileSystemNotificationIdentifier(path ?? new Path(Environment.CurrentDirectory), watcher, filter ?? "*", includeSubdirectories); FileSytemNotifierEntry entry; if (!Watchers.TryGetValue(id, out entry)) { lock (Watchers) { if (!Watchers.TryGetValue(id, out entry)) { Watchers.Add(id, entry = CreateEntry(id)); } } } return(entry.AddNotifiers(created, deleted, modified, renamed)); }
public abstract FileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier);