public unsafe Task SetDataObjectAsync(IDataObject data) { _native.Clear(); foreach (var fmt in data.GetDataFormats()) { var o = data.Get(fmt); if (o is string s) { _native.SetText(fmt, s); } else if (o is byte[] bytes) fixed(byte *pbytes = bytes) _native.SetBytes(fmt, pbytes, bytes.Length); } return(Task.CompletedTask); }
public unsafe Task SetDataObjectAsync(IDataObject data) { _native.Clear(); foreach (var fmt in data.GetDataFormats()) { var o = data.Get(fmt); if (o is string s) { using (var b = new Utf8Buffer(s)) _native.SetText(fmt, b.DangerousGetHandle()); } else if (o is byte[] bytes) fixed(byte *pbytes = bytes) _native.SetBytes(fmt, new IntPtr(pbytes), bytes.Length); } return(Task.CompletedTask); }