本文整理汇总了C#中Api.WaitForTorrentToStartByHash方法的典型用法代码示例。如果您正苦于以下问题:C# Api.WaitForTorrentToStartByHash方法的具体用法?C# Api.WaitForTorrentToStartByHash怎么用?C# Api.WaitForTorrentToStartByHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api.WaitForTorrentToStartByHash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetGeneralProperties
public async Task TestGetGeneralProperties()
{
var api = new Api(_serverCredential);
var uris = new[]
{
new Uri(
"magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
};
var hashes = new[]
{
"cd8158937344b2a066446bed7e7a0c45214f1245"
};
await api.DownloadFromUrls(uris);
await api.WaitForTorrentToBePausedByHash(hashes.FirstOrDefault());
await api.Resume(hashes.FirstOrDefault());
await api.WaitForTorrentToStartByHash(hashes.FirstOrDefault());
var generalProperties = await api.GetGeneralProperties(hashes.SingleOrDefault());
Assert.True(generalProperties.TimeElapsed >= 0);
await api.DeletePermanently(hashes);
}
示例2: TestGetProperties
public async Task TestGetProperties()
{
var api = new Api(_serverCredential);
var uris = new[]
{
new Uri(
"magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
};
var hashes = new[]
{
"cd8158937344b2a066446bed7e7a0c45214f1245"
};
await api.DownloadFromUrls(uris);
//await api.WaitForTorrentToBePausedByHash(hashes.FirstOrDefault());
//await api.Resume(hashes.FirstOrDefault());
await api.WaitForTorrentToStartByHash(hashes.FirstOrDefault());
var trackersPropertieses = await api.GetTrackersProperties(hashes.SingleOrDefault());
Assert.True(trackersPropertieses.Any(p => p.Url.Contains("http://bttracker.debian.org:6969/announce")));
var filesPropertieses = await api.GetFilesProperties(hashes.SingleOrDefault());
var file = filesPropertieses.Single();
Assert.Equal("debian-8.2.0-amd64-DVD-1.iso", file.Name);
Assert.Equal(3992977408, file.Size);
var transferInfo = await api.GetTransferInfo();
Assert.True(transferInfo.DhtNodes >= 0);
var setCategoryResult = await api.SetCategory(hashes, "linux-distro");
Assert.True(transferInfo.DhtNodes >= 0);
var recheckResult = await api.Recheck(hashes.SingleOrDefault());
Assert.True(recheckResult);
var addTrackerResult = await api.AddTrackers(hashes.SingleOrDefault(), new[] { new Uri("http://test1/"), new Uri("http://test2/") });
Assert.True(addTrackerResult);
await api.DeletePermanently(hashes);
}
示例3: TestDownloadFromUrls
public async Task TestDownloadFromUrls()
{
var api = new Api(_serverCredential);
var uris = new[]
{
new Uri(
"magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce"),
new Uri(
"magnet:?xt=urn:btih:e508e5f1c7ad6650eb41d38f29aa567923b3934f&dn=debian-8.2.0-amd64-DVD-2.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
};
var hashes = new[]
{
"cd8158937344b2a066446bed7e7a0c45214f1245",
"e508e5f1c7ad6650eb41d38f29aa567923b3934f"
};
var initialCount = (await api.GetTorrents()).Count;
await api.DownloadFromUrls(uris);
foreach(var hash in hashes)
{
//await api.WaitForTorrentToBePausedByHash(hash);
//await api.Resume(hash);
await api.WaitForTorrentToStartByHash(hash);
}
var after2AddCount = (await api.GetTorrents()).Count;
Assert.Equal(initialCount + 2, after2AddCount);
await api.DeletePermanently(hashes);
var after2Delete = (await api.GetTorrents()).Count;
Assert.Equal(initialCount, after2Delete);
}