// Retrieves array of identifiers of available formats. internal static int[] GetAvailableFormats(NSPasteboard pboard) { var ids = new List <int>(); var native = null == pboard.GetStringForType(Clipboard.IDataObjectFormat); if (native) { // Data in the pasteboard comes from another application foreach (var name in pboard.GetFormats()) { ids.Add(DataFormats.Format.Add(name).Id); } } else { // We provided the data for the pasteboard if (managed.TryGetValue(Clipboard.IDataObjectFormat, out object obj) && obj is IDataObject idata) { foreach (var fmt in idata.GetFormats()) { ids.Add(DataFormats.Format.Add(fmt).Id); } } foreach (var key in managed.Keys) { ids.Add(DataFormats.Format.Add(key).Id); } } return(ids.ToArray()); }