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


C# DataPackage.SetData方法代码示例

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


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

示例1: Contains_ReturnsTrueIfFormatIsAvailable

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

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

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

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

示例3: setString

 public void setString(string text)
 {
     RunOnDispatcher(() =>
     {
         if (text == null)
         {
             _clipboard.Clear();
         }
         else
         {
             var package = new DataTransfer.DataPackage();
             package.SetData(DataTransfer.StandardDataFormats.Text, text);
             _clipboard.SetContent(package);
         }
     });
 }
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:16,代码来源:ClipboardModule.cs

示例4: GetDataAsync_ThrowsException_IfFormatIdIsEmpty

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

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

            var e = await Assert.ThrowsAsync<ArgumentException>(() => sharePackage.GetDataAsync<string>(""));

            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

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

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


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