コード例 #1
0
        private IRenameOperation CreateRenameOperation(FileMessage message)
        {
            string oldPath = Path.Combine(_destinationPath, message.Harvester, message.FileName);
            string newPath = Path.Combine(_destinationPath, message.Harvester, message.NewName);

            return _renameOperationFactory.Invoke(oldPath, newPath);
        }
コード例 #2
0
        public IOperation Create(FileMessage message)
        {
            IOperation result;

            switch (message.OperationType)
            {
                case OperationType.Renamed:
                {
                    result = this.CreateRenameOperation(message);
                    break;
                }
                case OperationType.Synchronize:
                {
                    result = this.CreateSynchronizationOperation(message);
                    break;
                }
                default:
                {
                    result = this.CreateCopyOperation(message);
                    break;
                }
            }

            return result;
        }
コード例 #3
0
        public void Send(FileMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            message.Harvester = _harvester;

            _transferManager.Send(message);
        }
コード例 #4
0
        public async Task Perform()
        {
            using (var sourceStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, FileOptions.Asynchronous))
            {
                byte[] fileContent = new byte[sourceStream.Length];
                await sourceStream.ReadAsync(fileContent, 0, fileContent.Length);
                var message = new FileMessage
                {
                    FileContent = fileContent,
                    FileName = System.IO.Path.GetFileName(this.Path),
                    OperationType = OperationType.Changed
                };

                _fileSender.Send(message);
            }
        }
コード例 #5
0
 public CopyOperation(string destinationPath, FileMessage fileMessage)
 {
     _fileMessage = fileMessage;
     _path = System.IO.Path.Combine(destinationPath, fileMessage.FileName);
 }
コード例 #6
0
        private ISynchronizationOperation CreateSynchronizationOperation(FileMessage message)
        {
            ICopyOperation copyOperation = this.CreateCopyOperation(message);

            return _synchronizationOperationFactory.Invoke(copyOperation);
        }
コード例 #7
0
        private ICopyOperation CreateCopyOperation(FileMessage message)
        {
            string pathWithHarvesterName = Path.Combine(_destinationPath, message.Harvester);

            return _copyOperationFactory.Invoke(pathWithHarvesterName, message);
        }