public void PasteGherkin(IClipboard source) { if (!source.ContainsText()) return; var gherkinText = source.GetText() .Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim()); var gherkinTree = new GherkinTree(LineGenerators.CSharp, GWTIdentify); gherkinTree.AddLines(gherkinText); _environment.Paste(gherkinTree.ToString()); }
public ICollection <AnnoObject> Paste() { var files = _clipboard.GetFileDropList(); if (files?.Count == 1) { try { return(_layoutLoader.LoadLayout(files[0], forceLoad: true).Objects); } catch (JsonReaderException) { } } if (_clipboard.ContainsData(CoreConstants.AnnoDesignerClipboardFormat)) { try { var stream = _clipboard.GetData(CoreConstants.AnnoDesignerClipboardFormat) as Stream; if (stream is not null) { return(_layoutLoader.LoadLayout(stream, forceLoad: true).Objects); } } catch (JsonReaderException) { } } if (_clipboard.ContainsText()) { using var memoryStream = new MemoryStream(); using var streamWriter = new StreamWriter(memoryStream); streamWriter.Write(_clipboard.GetText()); streamWriter.Flush(); memoryStream.Seek(0, SeekOrigin.Begin); try { return(_layoutLoader.LoadLayout(memoryStream, forceLoad: true).Objects); } catch (JsonReaderException) { } } return(Array.Empty <AnnoObject>()); }
/// -------------------------------------------------------------------------------- /// <summary> /// Indicates whether there is data on the Clipboard in the Text or UnicodeText format, /// depending on the operating system. /// </summary> /// -------------------------------------------------------------------------------- public static bool ContainsText() { return(s_Clipboard.ContainsText()); }