public IDisposable RegisterNotification(Path path, string filter = "*", bool includeSubdirectories = false, Action<IFile> created = null, Action<IFile> modified = null, Action<IFile> deleted = null, Action<IFile> 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); IFileSytemNotifierEntry entry = null; 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 LocalFileSystemNotifierEntry(FileSystemNotificationIdentifier identity) { _actions = new List<Action<IFile>>(); _identity = identity; _watcher = new FileSystemWatcher { Filter = identity.Filter, IncludeSubdirectories = identity.IncludeSubDirectories, Path = identity.Path.FullPath }; }
public LocalFileSystemNotifierEntry(FileSystemNotificationIdentifier identity) { _actions = new List <Action <IFile> >(); _identity = identity; _watcher = new FileSystemWatcher { Filter = identity.Filter, IncludeSubdirectories = identity.IncludeSubDirectories, Path = identity.Path.FullPath }; }
public override IFileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier) { return new LocalFileSystemNotifierEntry(notificationIdentifier); }
private static bool PathMatches(FileSystemNotificationIdentifier key, IFile file) { return key.IncludeSubDirectories ? file.Parent.Path.FullPath.StartsWith(key.Path.FullPath, StringComparison.OrdinalIgnoreCase) : file.Parent.Path == key.Path; }
public InMemoryFileSystemNotifierEntry(FileSystemNotificationIdentifier notificationIdentifier) { Identifier = notificationIdentifier; }
public InMemoryFileSystemNotifierEntry(FileSystemNotificationIdentifier notificationIdentifier) { Identifier = notificationIdentifier; }
public override FileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier) { return(new LocalFileSystemNotifierEntry(notificationIdentifier)); }
private static bool PathMatches(FileSystemNotificationIdentifier key, IFile file) { return(key.IncludeSubDirectories ? file.Parent.Path.FullPath.StartsWith(key.Path.FullPath, StringComparison.OrdinalIgnoreCase) : file.Parent.Path == key.Path); }
public override IFileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier) { return(new InMemoryFileSystemNotifierEntry(notificationIdentifier)); }
public abstract IFileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier);
public override FileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier) { return new InMemoryFileSystemNotifierEntry(notificationIdentifier); }