示例#1
0
        /// <summary>
        /// Gets the data from a pasteboard of a specific type.
        /// </summary>
        /// <typeparam name="T">The data type of the data to retrieve.</typeparam>
        /// <param name="pasteboard">The pasteboard from which to retrieve data.</param>
        /// <param name="dataTypes">The data types expected to be supported by the pasteboard.</param>
        /// <returns>The data for given pasteboard data type, or <c>null</c> if the data is not supported or found.</returns>
        public static T GetDataForType <T>(NSPasteboard pasteboard, string[] dataTypes) where T : class
        {
            T data = default(T);

            if (pasteboard.CanReadItemWithDataConformingToTypes(dataTypes))
            {
                NSDataWrapper dataWrapper = null;
                if (PasteboardHelperData.TryGetValue(pasteboard, out dataWrapper))
                {
                    if (dataWrapper != null)
                    {
                        data = dataWrapper.GetWrappedObject <T>();
                    }
                }
            }
            return(data);
        }
 public static bool ContainsText()
 => pasteboard.CanReadItemWithDataConformingToTypes(textTypes);