Exemplo n.º 1
0
 private IAsyncOperation <TResult> GetData <TResult>(string format)
 {
     if (_data.TryGetValue(format, out var data))
     {
         return(data switch
         {
             DataProviderHandler provider => GetDataAsync <TResult>(format, provider).AsAsyncOperation(),
             _ => Task.FromResult((TResult)data).AsAsyncOperation()
         });
Exemplo n.º 2
0
        public static void SetApplicationLink(string formatId, DataProviderHandler dataProviderHandler)
        {
            var dp = new DataPackage();

            dp.RequestedOperation = DataPackageOperation.Copy;
            dp.SetDataProvider(formatId, dataProviderHandler);
            global::Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dp);
            global::Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sets a delegate to handle requests from the target app.
 /// </summary>
 /// <param name="formatId">Specifies the format of the data.
 /// We recommend that you set this value by using the StandardDataFormats class.</param>
 /// <param name="delayRenderer">A delegate that is responsible for processing requests from a target app.</param>
 public void SetDataProvider(string formatId, DataProviderHandler delayRenderer)
 {
     if (_data.ContainsKey(formatId))
     {
         _data[formatId] = delayRenderer;
     }
     else
     {
         _data.Add(formatId, delayRenderer);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sets a delegate to handle requests from the target app.
 /// </summary>
 /// <param name="formatId">Specifies the format of the data.
 /// We recommend that you set this value by using the StandardDataFormats class.</param>
 /// <param name="delayRenderer">A delegate that is responsible for processing requests from a target app.</param>
 public void SetDataProvider(string formatId, DataProviderHandler delayRenderer)
 {
     if (data.ContainsKey(formatId))
     {
         data[formatId] = delayRenderer;
     }
     else
     {
         data.Add(formatId, delayRenderer);
     }
 }
Exemplo n.º 5
0
        private Uri GetUri(string format)
        {
            if (_package._data.ContainsKey(format))
            {
                DataProviderHandler handler = _package._data[format] as DataProviderHandler;

                if (handler != null)
                {
                    DataProviderRequest request = new DataProviderRequest(_package, format);
                    handler.Invoke(request);
                }

                return((Uri)_package._data[format]);
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the text in the <see cref="DataPackageView"/> object.
        /// </summary>
        /// <returns></returns>
        public Task <string> GetTextAsync()
        {
            return(Task.Run <string>(() =>
            {
                if (_package._data.ContainsKey(StandardDataFormats.Text))
                {
                    DataProviderHandler handler = _package._data[StandardDataFormats.Text] as DataProviderHandler;

                    if (handler != null)
                    {
                        DataProviderRequest request = new DataProviderRequest(_package, StandardDataFormats.Text);
                        handler.Invoke(request);
                    }

                    return _package._data[StandardDataFormats.Text].ToString();
                }

                return null;
            }));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the data contained in the <see cref="DataPackageView"/>.
        /// </summary>
        /// <param name="formatId">The format of the data.</param>
        /// <returns>The data.</returns>
        public Task <object> GetDataAsync(string formatId)
        {
            return(Task.Run <object>(() =>
            {
                if (_package._data.ContainsKey(formatId))
                {
                    DataProviderHandler handler = _package._data[formatId] as DataProviderHandler;

                    if (handler != null)
                    {
                        DataProviderRequest request = new DataProviderRequest(_package, formatId);
                        handler.Invoke(request);
                    }
                    else
                    {
                        return _package._data[formatId];
                    }
                }

                return null;
            }));
        }
Exemplo n.º 8
0
 public void SetDataProvider( string formatId, DataProviderHandler delayRenderer )
 {
     adapted.SetDataProvider( formatId, delayRenderer );
 }
Exemplo n.º 9
0
 public void SetDataProvider(string formatId, DataProviderHandler delayRenderer)
 => SetData(formatId, delayRenderer);