public async Task <FileExistCheckResult> CheckIfFileExistsWithResultInOverlay(Job job, string latestConfirmedPath) { var filePath = job.OutputFileTemplate; //Do not inform user, if SaveFileDialog already did if (filePath == latestConfirmedPath) { return(new FileExistCheckResult(true, latestConfirmedPath)); } if (job.Profile.SaveFileTemporary || !_file.Exists(filePath)) { return(new FileExistCheckResult(true, latestConfirmedPath)); } _translation = _translationFactory.UpdateOrCreateTranslation(_translation); var title = _translation.ConfirmSaveAs.ToUpper(CultureInfo.CurrentCulture); var text = _translation.GetFileAlreadyExists(filePath); var interaction = new MessageInteraction(text, title, MessageOptions.YesNo, MessageIcon.Exclamation); var result = await _interactionRequest.RaiseAsync(interaction); if (result.Response == MessageResponse.Yes) { return(new FileExistCheckResult(true, filePath)); } return(new FileExistCheckResult(false, "")); }
private void UpdateTranslations(ITranslationFactory translationFactory) { _translation = translationFactory.UpdateOrCreateTranslation(_translation); foreach (var updateTranslationFunction in _updateTranslationFunctions) { updateTranslationFunction(_translation); } }
private MessageInteraction BuildInteraction(Job job, ActionResult profileCheckResult) { _translation = _translationFactory.UpdateOrCreateTranslation(_translation); var title = _translation.Error; var text = _translation.InvalidSettings; var interaction = new MessageInteraction(text, title, MessageOptions.OK, MessageIcon.Exclamation, job.Profile.Name, profileCheckResult); interaction.ShowErrorRegions = false; return(interaction); }
public void Initialize_UpdateOrCreateTranslationViaTranslationFactoryOfTranslationUpdater() { var translation = new TranslatableCommandBaseTestTranslation(); _translationFactory = Substitute.For <ITranslationFactory>(); _translationFactory.UpdateOrCreateTranslation(Arg.Any <TranslatableCommandBaseTestTranslation>()).Returns(translation); var translationUpdater = new TranslationUpdater(_translationFactory, new ThreadManager()); _translatableCommandBase = new TranslatableCommandBaseTestClass(translationUpdater); Assert.AreSame(translation, _translatableCommandBase.GetTranslation()); }
private async Task <QueryResult <OutputFilenameResult> > GetFileOrRetry(string dir, string file, OutputFormat format) { while (true) { try { return(_fileNameQuery.GetFileName(dir, file, format)); } catch (PathTooLongException) { _translation = _translationFactory.UpdateOrCreateTranslation(_translation); var interaction = new MessageInteraction(_translation.PathTooLongText, _translation.PathTooLongTitle, MessageOptions.OK, MessageIcon.Exclamation); await _interactionRequest.RaiseAsync(interaction); } } }
public T UpdateOrCreateTranslation<T>(T translation) where T : ITranslatable, new() { var type = typeof(T); var isCached = _instanceCache.ContainsKey(type); if (_updateCache.Contains(translation)) return translation; if (translation == null && isCached) return (T)_instanceCache[type]; translation = _baseTranslationFactory.UpdateOrCreateTranslation(translation); if (!isCached) _instanceCache[type] = translation; _updateCache.Add(translation); return translation; }
private void SetTranslationAction(ITranslationFactory tf) { Translation = tf.UpdateOrCreateTranslation(Translation); }
private void UpdateTranslation <T>(ITranslationFactory translationFactory, ITranslatableViewModel <T> viewModel) where T : ITranslatable, new() { viewModel.Translation = translationFactory.UpdateOrCreateTranslation(viewModel.Translation); }