當前位置: 首頁>>代碼示例>>C#>>正文


C# DataPackage.SetAsyncDataProvider方法代碼示例

本文整理匯總了C#中Windows.ApplicationModel.DataTransfer.DataPackage.SetAsyncDataProvider方法的典型用法代碼示例。如果您正苦於以下問題:C# DataPackage.SetAsyncDataProvider方法的具體用法?C# DataPackage.SetAsyncDataProvider怎麽用?C# DataPackage.SetAsyncDataProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.ApplicationModel.DataTransfer.DataPackage的用法示例。


在下文中一共展示了DataPackage.SetAsyncDataProvider方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetAsyncDataProvider_ReturnsValueFromSyncTask

        public async Task SetAsyncDataProvider_ReturnsValueFromSyncTask()
        {
            DataPackage dataPackage = new DataPackage();

            dataPackage.SetAsyncDataProvider(StandardDataFormats.Text, (formatId, deadline) =>
            {
                return Task.FromResult<object>("Test text");
            });

            DataPackageView dataPackageView = dataPackage.GetView();
            string result = await dataPackageView.GetTextAsync();

            Assert.AreEqual("Test text", result);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:14,代碼來源:DataPackageExFixture.cs

示例2: SetAsyncDataProvider_ReturnsValueFromAsyncTask

        public async Task SetAsyncDataProvider_ReturnsValueFromAsyncTask()
        {
            DataPackage dataPackage = new DataPackage();

            dataPackage.SetAsyncDataProvider(StandardDataFormats.Text, async (formatId, deadline) =>
                {
                    await Task.Delay(200);
                    return "Test text";
                });

            DataPackageView dataPackageView = dataPackage.GetView();
            string result = await dataPackageView.GetTextAsync();

            Assert.AreEqual("Test text", result);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:15,代碼來源:DataPackageExFixture.cs

示例3: SetAsyncDataProvider_PassesDeadlineToMethod

        public async Task SetAsyncDataProvider_PassesDeadlineToMethod()
        {
            DataPackage dataPackage = new DataPackage();

            DateTimeOffset deadlineValue = DateTimeOffset.MinValue;

            dataPackage.SetAsyncDataProvider(StandardDataFormats.Text, (formatId, deadline) =>
            {
                deadlineValue = deadline;
                return Task.FromResult<object>("Test text");
            });

            DataPackageView dataPackageView = dataPackage.GetView();
            string result = await dataPackageView.GetTextAsync();

            Assert.AreNotEqual(DateTimeOffset.MinValue, deadlineValue);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:17,代碼來源:DataPackageExFixture.cs

示例4: SetAsyncDataProvider_PassesFormatIdToMethod

        public async Task SetAsyncDataProvider_PassesFormatIdToMethod()
        {
            DataPackage dataPackage = new DataPackage();

            string formatIdValue = null;

            dataPackage.SetAsyncDataProvider(StandardDataFormats.Text, (formatId, deadline) =>
            {
                formatIdValue = formatId;
                return Task.FromResult<object>("Test text");
            });

            DataPackageView dataPackageView = dataPackage.GetView();
            string result = await dataPackageView.GetTextAsync();

            Assert.AreEqual(StandardDataFormats.Text, formatIdValue);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:17,代碼來源:DataPackageExFixture.cs


注:本文中的Windows.ApplicationModel.DataTransfer.DataPackage.SetAsyncDataProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。