public IEnumerable<IResult> Export() { var saveFileResult = new SaveFileResult() .FilterFiles(x => x.AddFilter("csv", isDefault: true).WithDescription("CSV Datei")) .In(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)); yield return saveFileResult; var exportResult = new DelegateResult(() => CsvImporter.Export(BarcodeManager.Barcodes, saveFileResult.FileName)); yield return exportResult .Rescue().With(coroutine: ExportRescue); }
public IEnumerable<IResult> Import() { var openFileResult = new OpenFileResult() .FilterFiles(x => x.AddFilter("csv", isDefault: true).WithDescription("CSV Datei")) .In(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)); yield return openFileResult .Rescue().With(coroutine: ImportRescue); var clearBeforeQuestion = new Question("Frage", "Aktuelle Liste vor dem Import verwerfen?", Answer.Yes, Answer.No); yield return clearBeforeQuestion.AsResult(); var importResult = new DelegateResult(() => { if (clearBeforeQuestion.GivenResponse == Answer.Yes) { BarcodeManager.Clear(); } foreach (var barcode in CsvImporter.Import(openFileResult.FileName)) { BarcodeManager.Import(barcode); } }); yield return importResult .Rescue().With(coroutine: ImportRescue); }