本文整理汇总了C#中Torrent类的典型用法代码示例。如果您正苦于以下问题:C# Torrent类的具体用法?C# Torrent怎么用?C# Torrent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Torrent类属于命名空间,在下文中一共展示了Torrent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTorrentDialog
public LoadTorrentDialog(Torrent torrent, string defaultPath)
{
if (torrent == null)
throw new System.ArgumentNullException ("torrent");
if (defaultPath == null)
throw new System.ArgumentNullException ("defaultPath");
this.Build();
PopulateStore (torrent);
BuildColumns();
this.lblName.Text = torrent.Name;
this.lblSize.Text = ByteConverter.ConvertSize (torrent.Size);
if (!string.IsNullOrEmpty(defaultPath))
fileChooser.SetCurrentFolder(defaultPath);
}
示例2: Television
public Television(TLFeed feed, Database database, Collector collector, Torrenter torrenter)
{
feed.New += item =>
{
if (item.Categories[0].Name != "Episodes")
return;
var shows = database.Get<Show>();
if (shows.Any(show => item.Title.Text.ToLower().Contains(show.Title.ToLower())))
{
var model = new Torrent(item.Title.Text, item.Links.First().Uri.ToString(), item.Categories.First().Name);
collector.Event(model);
torrenter.Download(item.Links.First().Uri.ToString());
}
};
collector.On<Search>(search =>
{
var wc = new WebClient();
var result = wc.DownloadString("http://www.imdb.com/xml/find?json=1&tt=on&q=" + search.Query);
try
{
var json = JObject.Parse(result);
var exact = json["title_popular"];
if (exact == null) return;
if(!exact["description"].ToString().Contains("TV")) return;
var show = new Show(exact[0]["title"].ToString());
collector.Event(show);
}
catch { }
});
}
示例3: InfoHashTrackable
public InfoHashTrackable(Torrent torrent)
{
Check.Torrent(torrent);
name = torrent.Name;
infoHash = torrent.InfoHash;
}
示例4: Main
static void Main(string[] args)
{
Torrent torrent = new Torrent(BenDecoder.Decode(args[0]));
Tracker trackerClient = new Tracker(torrent);
Console.WriteLine("Connecting to tracker at {0}", torrent.AnnounceUri);
object cv = new object();
trackerClient.Connected += delegate
{
Console.WriteLine("Connected to {0}", torrent.AnnounceUri);
};
trackerClient.Updated += delegate
{
if(trackerClient.LastResponse.IsSuccessful)
{
Console.WriteLine("{0} Seeders, {1} leechers", trackerClient.LastResponse.NumberOfSeeds, trackerClient.LastResponse.NumberOfLeechers);
ConnectToPeers(trackerClient.LastResponse.Peers, torrent);
}
else
{
QuitWithError(cv, trackerClient.LastResponse.FailureReason);
}
};
trackerClient.Error += delegate(object sender, Exception e)
{
QuitWithError(cv, e.Message);
};
trackerClient.Start();
lock(cv)
{
Monitor.Wait(cv);
}
}
示例5: TorrentGetCommand
public TorrentGetCommand(JsonObject response)
{
Program.DaemonDescriptor.ResetFailCount();
if (!Program.Connected)
{
return;
}
JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS];
JsonArray torrents = (JsonArray)arguments[ProtocolConstants.KEY_TORRENTS];
Program.DaemonDescriptor.UpdateSerial++;
oldCount = Program.TorrentIndex.Count;
UpdateTorrents.Clear();
for (int i = 0; i < torrents.Count; i++)
{
JsonObject torrent = (JsonObject)torrents[i];
string hash = (string)torrent[ProtocolConstants.FIELD_HASHSTRING];
Torrent t = null;
lock (Program.TorrentIndex)
{
if (!Program.TorrentIndex.ContainsKey(hash))
{
t = new Torrent(torrent);
}
else
{
t = Program.TorrentIndex[hash];
if (t.Update(torrent, false))
stateChange = true;
}
UpdateTorrents.Add(t);
}
totalUpload += t.UploadRate;
totalDownload += t.DownloadRate;
}
}
示例6: SetUp
public void SetUp()
{
socket = new FakeSocket();
file = TorrentTestUtils.CreateMultiFileTorrent();
socket.response = TrackerResponseTest.CreateTestResponseString();
}
示例7: TorrentViewModel
public TorrentViewModel(Torrent torrent, IEventAggregator eventAggregator, ErrorTracker errorTracker, ServerUnits speedUnits, ServerUnits sizeUnits)
{
Id = torrent.ID;
TorrentFileViewModel = new TorrentFileViewModel(Id, eventAggregator, errorTracker);
Size = torrent.Size.ToSizeString(sizeUnits);
Hash = torrent.Hash;
Update(torrent, speedUnits, sizeUnits);
}
示例8: HashFileLinkPieces
public HashFileLinkPieces(Torrent torrent, int pieceIndex,
IList<FileLinkPiece> fileLinkPieces)
{
this._pieceIndex = pieceIndex;
this._fileLinkPieces = fileLinkPieces;
this._result = -1;
this._torrent = torrent;
}
示例9: InfoHashTrackable
public InfoHashTrackable(Torrent torrent)
{
if (torrent == null)
throw new ArgumentNullException("torrent");
name = torrent.Name;
infoHash = torrent.InfoHash;
}
示例10: CustomITrackable
public CustomITrackable(Torrent t)
{
// Note: I'm just storing the files, infohash and name. A typical Torrent instance
// is ~100kB in memory. A typical CustomITrackable will be ~100 bytes.
files = t.Files;
infoHash = t.InfoHash;
name = t.Name;
}
示例11: TorrentTracker
/// <summary>
///
/// </summary>
/// <param name="torrent"></param>
/// <param name="tracker"></param>
public TorrentTracker(Torrent torrent, Tracker tracker)
{
Torrent = torrent;
Tracker = tracker;
Peers = new List<Peer>();
// par défaut, les peers ne sont pas compactés
Compact = false;
}
示例12: TorrentRandomAccessStream
public TorrentRandomAccessStream(TorrentStreamManager manager)
{
_manager = manager;
_torrentFile = manager.TorrentVideoFile;
_torrent = manager.Torrent;
var stream = File.Open(Path.Combine(_torrentFile.TargetFolder.Path, _torrentFile.Path), FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
_internalStream = stream.AsRandomAccessStream();
}
示例13: CreateTorrentState
public TorrentState CreateTorrentState(Torrent t)
{
var hash = ExtractHash(t.Magnet);
var ts = new TorrentState(hash, t.Episode.Season, t.Episode.Number);
_tracked.Add(new WeakReference(ts));
return ts;
}
示例14: HdknTorrent
internal HdknTorrent(Torrent torrent)
{
_torrent = torrent;
foreach (var file in torrent.Files)
{
_files.Add(new HdknTorrentFile(file));
}
}
示例15: VerifyCommonParts
private void VerifyCommonParts(Torrent torrent)
{
Assert.Equal(Comment, torrent.Comment);
Assert.Equal(CreatedBy, torrent.CreatedBy);
Assert.True(DateTime.Now - torrent.CreationDate < TimeSpan.FromSeconds(5));
Assert.Equal(PieceLength, torrent.PieceLength);
Assert.Equal(Publisher, torrent.Publisher);
Assert.Equal(PublisherUrl, torrent.PublisherUrl);
Assert.Equal(2, torrent.AnnounceUrls.Count);
Assert.Equal(2, torrent.AnnounceUrls[0].Count);
Assert.Equal(2, torrent.AnnounceUrls[1].Count);
}