public async Task PasteSelectedFilesAsync(string destinationDirectory) { var selectedFilesString = await _clipboardService.GetTextAsync(); var startIndex = UrlPrefix.Length; var files = selectedFilesString .Split() .Select(f => f.Substring(startIndex)) .ToArray(); await _operationsService.CopyFilesAsync(files, destinationDirectory); }
public void CopyClipboardTextWhenApplicationBecomesVisible() { const string clipboardText = "SomeText"; var visibilitySubject = new Subject <bool>(); A.CallTo(() => _clipboardService.GetTextAsync(A <CancellationToken> .Ignored)).Returns(Task.FromResult(Option <string> .AsOption(clipboardText))); A.CallTo(() => _windowService.IsVisibleObservable).Returns(visibilitySubject); var viewModel = CreateViewModel(); visibilitySubject.OnNext(true); Assert.AreEqual(clipboardText, viewModel.Text.Value); }
public async Task PasteFilesAsync(string destinationDirectory) { var selectedFilesString = await _clipboardService.GetTextAsync(); if (string.IsNullOrWhiteSpace(selectedFilesString)) { return; } var startIndex = UrlPrefix.Length; var files = selectedFilesString .Split() .Where(t => t.StartsWith(UrlPrefix)) .Select(f => f[startIndex..])
private async Task <IReadOnlyList <string> > GetFilesAsync() { var selectedFilesString = await _clipboardService.GetTextAsync(); if (string.IsNullOrWhiteSpace(selectedFilesString)) { return(Array.Empty <string>()); } var startIndex = UrlPrefix.Length; return(selectedFilesString .Split(_environmentService.NewLine) .Where(t => t.StartsWith(UrlPrefix)) .Select(f => f[startIndex..])
public async Task PasteFilesAsync(string destinationDirectory) { var selectedFilesString = await _clipboardService.GetTextAsync(); if (string.IsNullOrWhiteSpace(selectedFilesString)) { return; } var startIndex = UrlPrefix.Length; var files = selectedFilesString .Split() .Where(t => t.StartsWith(UrlPrefix)) .Select(f => f.Substring(startIndex)) .ToArray(); if (files.Any()) { await _operationsService.CopyAsync(files, destinationDirectory); } }