本文整理汇总了C#中Api.SetCategory方法的典型用法代码示例。如果您正苦于以下问题:C# Api.SetCategory方法的具体用法?C# Api.SetCategory怎么用?C# Api.SetCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api.SetCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: TestUpload
public async Task TestUpload()
{
var api = new Api(_serverCredential);
var initialTorrents = await api.GetTorrents();
var bytes = new[]
{
await
new HttpClient().GetByteArrayAsync(
new Uri("http://releases.ubuntu.com/16.04/ubuntu-16.04-desktop-amd64.iso.torrent")),
await
new HttpClient().GetByteArrayAsync(
new Uri("http://releases.ubuntu.com/16.04/ubuntu-16.04-desktop-i386.iso.torrent"))
};
await api.Upload(bytes);
await api.WaitForTorrentToStartByName("ubuntu-16.04-desktop-amd64.iso");
await api.WaitForTorrentToStartByName("ubuntu-16.04-desktop-i386.iso");
var afterUploadTorrents = await api.GetTorrents();
Assert.Equal(initialTorrents.Count + bytes.Length, afterUploadTorrents.Count);
var hashList =
afterUploadTorrents.Select(t => t.Hash)
.ToList()
.Except(initialTorrents.Select(t => t.Hash).ToList())
.ToList();
Assert.Equal(bytes.Length, hashList.Count());
var setCategoryResult = await api.SetCategory(hashList, "ubuntu");
await api.DeletePermanently(hashList);
var afterDeleteTorrents = await api.GetTorrents();
Assert.Equal(afterDeleteTorrents.Count, initialTorrents.Count);
}