Exemplo n.º 1
0
		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;
		}
Exemplo n.º 6
0
 public InMemoryFileSystemNotifierEntry(FileSystemNotificationIdentifier notificationIdentifier)
 {
     Identifier = notificationIdentifier;
 }
		public InMemoryFileSystemNotifierEntry(FileSystemNotificationIdentifier notificationIdentifier)
		{
			Identifier = notificationIdentifier;
		}
Exemplo n.º 8
0
 public override FileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier)
 {
     return(new LocalFileSystemNotifierEntry(notificationIdentifier));
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 public override IFileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier)
 {
     return(new InMemoryFileSystemNotifierEntry(notificationIdentifier));
 }
Exemplo n.º 11
0
		public abstract IFileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier);
Exemplo n.º 12
0
 public override FileSytemNotifierEntry CreateEntry(FileSystemNotificationIdentifier notificationIdentifier)
 {
     return new InMemoryFileSystemNotifierEntry(notificationIdentifier);
 }