当前位置: 首页>>代码示例>>C#>>正文


C# DataPackage.GetView方法代码示例

本文整理汇总了C#中Windows.ApplicationModel.DataTransfer.DataPackage.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# DataPackage.GetView方法的具体用法?C# DataPackage.GetView怎么用?C# DataPackage.GetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.ApplicationModel.DataTransfer.DataPackage的用法示例。


在下文中一共展示了DataPackage.GetView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Properties_Description_GetsValueFromDataPackageView

        public void Properties_Description_GetsValueFromDataPackageView()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.Properties.Description = "Test Value";

            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            Assert.Equal("Test Value", sharePackage.Properties.Description);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:SharePackageViewFixture.cs

示例2: Properties_Title_GetsValueFromDataPackageView

        public void Properties_Title_GetsValueFromDataPackageView()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.Properties.Title = "Test Value";

            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            Assert.Equal("Test Value", sharePackage.Properties.Title);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:SharePackageViewFixture.cs

示例3: Properties_Title_SettingValueThrowsException

        public void Properties_Title_SettingValueThrowsException()
        {
            DataPackage dataPackage = new DataPackage();
            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            var e = Assert.Throws<InvalidOperationException>(() => sharePackage.Properties.Description = "Test Value");

            Assert.Equal("Cannot modify share properties as a share target.", e.Message);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:SharePackageViewFixture.cs

示例4: SetData_SetsDataOnDataPackage

        public async Task SetData_SetsDataOnDataPackage()
        {
            DataPackage dataPackage = new DataPackage();
            SharePackage sharePackage = new SharePackage(dataPackage);

            sharePackage.SetData<string>("Test Format", "Test Value");

            object data = await dataPackage.GetView().GetDataAsync("Test Format");
            Assert.Equal("Test Value", data);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:SharePackageFixture.cs

示例5: AvailableFormats_ReturnsValuesFromDataPackageView

        public void AvailableFormats_ReturnsValuesFromDataPackageView()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.SetData("Format A", "Some data");
            dataPackage.SetData("Format B", "Some data");

            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            Assert.Equal(2, sharePackage.AvailableFormats.Count);
            Assert.Contains("Format A", sharePackage.AvailableFormats.ToList());
            Assert.Contains("Format B", sharePackage.AvailableFormats.ToList());
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:12,代码来源:SharePackageViewFixture.cs

示例6: 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

示例7: SetAsyncData_SetsDataOnDataPackage

        public async Task SetAsyncData_SetsDataOnDataPackage()
        {
            DataPackage dataPackage = new DataPackage();
            SharePackage sharePackage = new SharePackage(dataPackage);

            sharePackage.SetAsyncData("Test Format", async (state) =>
                {
                    await Task.Delay(200);
                    return "Test Value";
                });

            object data = await dataPackage.GetView().GetDataAsync("Test Format");
            Assert.Equal("Test Value", data);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:14,代码来源:SharePackageFixture.cs

示例8: 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

示例9: 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

示例10: 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

示例11: Contains_ThrowsException_IfFormatIdIsNull

        public void Contains_ThrowsException_IfFormatIdIsNull()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.SetData("Format A", "Some data");
            dataPackage.SetData("Format B", "Some data");

            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            var e = Assert.Throws<ArgumentException>(() => sharePackage.Contains(null));

            Assert.Equal("The argument cannot be null or an empty string.\r\nParameter name: formatId", e.Message);
            Assert.Equal("formatId", e.ParamName);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:13,代码来源:SharePackageViewFixture.cs

示例12: Contains_ReturnsFalseIfFormatIsNotAvailable

        public void Contains_ReturnsFalseIfFormatIsNotAvailable()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.SetData("Format A", "Some data");
            dataPackage.SetData("Format B", "Some data");

            SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());

            Assert.False(sharePackage.Contains("Format C"));
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:SharePackageViewFixture.cs

示例13: SetAsyncUri_ReturnsValueFromAsyncTask

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

            dataPackage.SetAsyncUri(async (formatId, deadline) =>
            {
                await Task.Delay(200);
                return new Uri("http://www.example.org/");
            });

            DataPackageView dataPackageView = dataPackage.GetView();
            Uri result = await dataPackageView.GetUriAsync();

            Assert.AreEqual("http://www.example.org/", result.AbsoluteUri);
        }
开发者ID:Valks,项目名称:Okra,代码行数:15,代码来源:DataPackageExFixture.cs

示例14: GetDataAsync_GetsDataFromDataPackage

        public async Task GetDataAsync_GetsDataFromDataPackage()
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.SetData("Test Format", "Test Value");

            SharePackageView sharePackageView = new SharePackageView(dataPackage.GetView());
            string data = await sharePackageView.GetDataAsync<string>("Test Format");

            Assert.Equal("Test Value", data);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:SharePackageViewFixture.cs

示例15: SetAsyncStorageItems_ReturnsValueFromAsyncTask

        public async Task SetAsyncStorageItems_ReturnsValueFromAsyncTask()
        {
            DataPackage dataPackage = new DataPackage();
            StorageFile file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("Test file.xml");

            dataPackage.SetAsyncStorageItems(async (formatId, deadline) =>
            {
                await Task.Delay(200);
                return new IStorageItem[] { file };
            });

            DataPackageView dataPackageView = dataPackage.GetView();
            IReadOnlyList<IStorageItem> result = await dataPackageView.GetStorageItemsAsync();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(file.Path, result[0].Path);
        }
开发者ID:Valks,项目名称:Okra,代码行数:17,代码来源:DataPackageExFixture.cs


注:本文中的Windows.ApplicationModel.DataTransfer.DataPackage.GetView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。