コード例 #1
0
        public void Run(IProgressReporter progressReporter, CancellationToken cancellationToken)
        {
            if (_srcStorage == null || _dstFilePath == null)
            {
                throw new InvalidOperationException($"{nameof(Setup)} should be called first.");
            }

            try
            {
                _streamToFileHelper.Save(_srcStorage.AsStream(), _dstFilePath, cancellationToken, progressReporter.SetPercentage);
            }
            catch (OperationCanceledException)
            {
                _logger.LogWarning(LocalizationManager.Instance.Current.Keys.Log_SaveStorageCanceled);
            }
        }
コード例 #2
0
        public void Run(IProgressReporter progressReporter, CancellationToken cancellationToken)
        {
            if (_srcFile == null || _dstFilePath == null)
            {
                throw new InvalidOperationException($"{nameof(Setup)} should be called first.");
            }

            var progressText = LocalizationManager.Instance.Current.Keys.Status_SavingFile.SafeFormat(Path.GetFileName(_dstFilePath));

            progressReporter.SetText(progressText);

            try
            {
                _streamToFileHelper.Save(_srcFile.AsStream(), _dstFilePath, cancellationToken, progressReporter.SetPercentage);
            }
            catch (OperationCanceledException)
            {
                _logger.LogWarning(LocalizationManager.Instance.Current.Keys.Log_SaveFileCanceled);
            }
        }