public IOperation Create(FileSystemWatcherEventArgs eventArgs, string destinationPath)
        {
            IOperation result;

            switch (eventArgs.ChangeType)
            {
                case FileSystemWatcherChangeType.Renamed:
                {
                    result = this.CreateRenameOperation(eventArgs, destinationPath);
                    break;
                }
                case FileSystemWatcherChangeType.Synchronize:
                {
                    result = this.CreateSynchronizeOperation(eventArgs, destinationPath);
                    break;
                }
                default:
                {
                    result = this.CreateCopyOperation(eventArgs, destinationPath);
                    break;
                }
            }

            return result;
        }
 private void OnFolderStateChanged(object sender, FileSystemWatcherEventArgs fileSystemWatcherEventArgs)
 {
     lock (_sync)
     {
         _operationQueue.Enqueue(fileSystemWatcherEventArgs);
         Monitor.Pulse(_sync);
     }
 }
        private string GetKey(FileSystemWatcherEventArgs watchArg)
        {
            var renameArgs = watchArg as FileSystemWatcherRenameEventArgs;
            if (renameArgs != null)
            {
                return renameArgs.OldPath;
            }

            return watchArg.FullPath;
        }
        private IOperation CreateRenameOperation(FileSystemWatcherEventArgs eventArgs, string destinationPath)
        {
            var renameArgs = eventArgs as FileSystemWatcherRenameEventArgs;
            if (renameArgs == null)
            {
                throw new ArgumentException("The operation is specified as 'Rename' but the actual arguments is different.");
            }

            string oldFullPath = Path.Combine(destinationPath, renameArgs.OldName);
            string newFullPath = Path.Combine(destinationPath, renameArgs.Name);
            return _renameOperationFactory.Invoke(oldFullPath, newFullPath);
        }
 private IOperation CreateSynchronizeOperation(FileSystemWatcherEventArgs eventArgs, string destinationPath)
 {
     string destinationFullPath = Path.Combine(destinationPath, eventArgs.Name);
     return _synchronizationOperationFactory.Invoke(eventArgs.FullPath, destinationFullPath);
 }