public NetWatcher(
FileSystemWatcher watcher,
ISyncEventQueue queue,
IMetaDataStorage storage,
FileSystemInfoFactory fsFactory = null)
{
if (watcher == null) {
throw new ArgumentNullException("watcher");
}
if (string.IsNullOrEmpty(watcher.Path)) {
throw new ArgumentException("The given watcher must contain a path, where it is listening");
}
if (queue == null) {
throw new ArgumentNullException("queue");
}
if (storage == null) {
throw new ArgumentNullException("storage");
}
this.fsFactory = fsFactory ?? new FileSystemInfoFactory();
this.queue = queue;
this.storage = storage;
this.fileSystemWatcher = watcher;
this.fileSystemWatcher.IncludeSubdirectories = true;
this.fileSystemWatcher.Filter = "*";
this.fileSystemWatcher.InternalBufferSize = 4 * 1024 * 16;
this.fileSystemWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite | NotifyFilters.Security;
this.createChangeDeleteHandler = new CreatedChangedDeletedFileSystemEventHandler(this.queue, this.storage, this.fsFactory);
this.renamedHandler = new RenamedFileSystemEventHandler(this.queue, this.fsFactory);
this.fileSystemWatcher.Created += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle);
this.fileSystemWatcher.Deleted += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle);
this.fileSystemWatcher.Changed += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle);
this.fileSystemWatcher.Renamed += new RenamedEventHandler(this.renamedHandler.Handle);
}