本文整理汇总了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"));
}
示例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());
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例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);
}