public void Perform() { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } var fileContent = reader.Read(openFileDialog.FileName); var splittedWords = analyzer.SplitWords(fileContent); wordsRepository.Load(splittedWords); } }
public void Perform() { using (var openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } Result.Of(() => reader.Read(openFileDialog.FileName)) .Then(fileContent => analyzer.SplitWords(fileContent)) .Then(splitWords => wordsRepository.Load(splitWords)) .RefineError("Failed, trying to load excluding words") .OnFail(exceptionHandler.HandleException); } }