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