本文整理汇总了C#中Torrent类的典型用法代码示例。如果您正苦于以下问题:C# Torrent类的具体用法?C# Torrent怎么用?C# Torrent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Torrent类属于命名空间,在下文中一共展示了Torrent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:ArsenShnurkov,项目名称:monsoon,代码行数:16,代码来源:LoadTorrentDialog.cs
示例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 { }
});
}
开发者ID:jarvis-systems,项目名称:Cortex,代码行数:32,代码来源:Television.cs
示例3: InfoHashTrackable
public InfoHashTrackable(Torrent torrent)
{
Check.Torrent(torrent);
name = torrent.Name;
infoHash = torrent.InfoHash;
}
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:7,代码来源:InfoHashTrackable.cs
示例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);
}
}
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:33,代码来源:Program.cs
示例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;
}
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:35,代码来源:TorrentGetCommand.cs
示例6: SetUp
public void SetUp()
{
socket = new FakeSocket();
file = TorrentTestUtils.CreateMultiFileTorrent();
socket.response = TrackerResponseTest.CreateTestResponseString();
}
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:7,代码来源:TrackerTests.cs
示例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);
}
开发者ID:alexhardwicke,项目名称:Surge,代码行数:8,代码来源:TorrentViewModel.cs
示例8: HashFileLinkPieces
public HashFileLinkPieces(Torrent torrent, int pieceIndex,
IList<FileLinkPiece> fileLinkPieces)
{
this._pieceIndex = pieceIndex;
this._fileLinkPieces = fileLinkPieces;
this._result = -1;
this._torrent = torrent;
}
开发者ID:harrywong,项目名称:torrenthardlinkhelper,代码行数:8,代码来源:HashFileLinkPieces.cs
示例9: InfoHashTrackable
public InfoHashTrackable(Torrent torrent)
{
if (torrent == null)
throw new ArgumentNullException("torrent");
name = torrent.Name;
infoHash = torrent.InfoHash;
}
开发者ID:burris,项目名称:monotorrent,代码行数:8,代码来源:InfoHashTrackable.cs
示例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;
}
开发者ID:stojy,项目名称:monotorrent,代码行数:8,代码来源:Main.cs
示例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;
}
开发者ID:jbauzone,项目名称:JTorrent,代码行数:14,代码来源:TorrentTracker.cs
示例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();
}
开发者ID:haroldma,项目名称:PopcornTime,代码行数:9,代码来源:TorrentRandomAccessStream.cs
示例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;
}
开发者ID:pakrym,项目名称:GetMyShows,代码行数:9,代码来源:TorrentManager.cs
示例14: HdknTorrent
internal HdknTorrent(Torrent torrent)
{
_torrent = torrent;
foreach (var file in torrent.Files)
{
_files.Add(new HdknTorrentFile(file));
}
}
开发者ID:arenhag,项目名称:hdkn,代码行数:9,代码来源:HdknTorrent.cs
示例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);
}
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:12,代码来源:TorrentCreatorTests.cs
示例16: WebMultiDownload
public WebMultiDownload(IEnumerable<string> links, string targetFilePath, string tempFolder, Torrent torrent)
{
this.torrent = torrent;
Length = (int)torrent.Size;
Name = torrent.Name;
urls = new List<string>(links);
this.targetFilePath = targetFilePath;
pieceStates = new PieceState[torrent.Pieces.Count];
for (var i = 0; i < pieceStates.Length; i++) pieceStates[i] = PieceState.Free;
if (tempFolder != null) tempFilePath = Utils.MakePath(tempFolder, Path.GetFileName(targetFilePath));
else tempFilePath = Path.GetTempFileName();
}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:13,代码来源:WebMultiDownload.cs
示例17: StartDownloadingFile
/// <summary>
/// Adds the file to download. This method returns when the torrent is
/// added and doesn't wait for the download to complete.
/// </summary>
/// <param name="torrent">The torrent.</param>
/// <param name="savePath">The save path.</param>
public void StartDownloadingFile(Torrent torrent, string savePath, int lastPieceInProfile)
{
TorrentSettings torrentDefaults = new TorrentSettings(4, 150, 0, 0);
var tm = new TorrentManager(torrent, savePath, torrentDefaults, "", lastPieceInProfile);
// There is no need to scrape since we manage the tracker.
tm.TrackerManager.CurrentTracker.CanScrape = false;
_clientEngine.Register(tm);
tm.TrackerManager.CurrentTracker.AnnounceComplete +=
new EventHandler<AnnounceResponseEventArgs>(
TorrentEventHandlers.HandleAnnounceComplete);
tm.TrackerManager.CurrentTracker.ScrapeComplete += delegate(object o, ScrapeResponseEventArgs e) {
logger.DebugFormat("Scrape completed. Successful={0}, Tracker={1}",
e.Successful, e.Tracker.Uri);
};
tm.TorrentStateChanged +=
new EventHandler<TorrentStateChangedEventArgs>(
TorrentEventHandlers.HandleTorrentStateChanged);
tm.PieceHashed +=
new EventHandler<PieceHashedEventArgs>(
TorrentEventHandlers.HandlePieceHashed);
tm.PeerConnected += delegate(object o, PeerConnectionEventArgs e) {
// Only log three connections.
if (e.TorrentManager.OpenConnections < 4) {
logger.DebugFormat(
"Peer ({0}) Connected. Currently {1} open connection.",
e.PeerID.Uri, e.TorrentManager.OpenConnections);
}
};
tm.PieceManager.BlockReceived += delegate(object o, BlockEventArgs e) {
logger.DebugFormat("Block {0} from piece {1} is received.", e.Block.StartOffset / Piece.BlockSize, e.Piece.Index);
};
// We really only deal with one file.
foreach (var file in tm.Torrent.Files) {
_torrentManagerTable[file.FullPath] = tm;
}
tm.Start();
logger.DebugFormat(
"Starting to download torrent: {0}. Torrent manager started.",
tm.Torrent.Name);
}
开发者ID:xujyan,项目名称:hurricane,代码行数:55,代码来源:VirtualDiskDownloadService.cs
示例18: TorrentAdapter
public TorrentAdapter(Torrent torrent, ObjectPath path)
{
this.path = path;
this.torrent = torrent;
this.filesPath = path.ToString () + "/files/{0}";
files = new ObjectPath[torrent.Files.Length];
for (int i=0; i < files.Length; i++)
{
ObjectPath p = new ObjectPath (string.Format(filesPath, i));
TorrentFileAdapter adapter = new TorrentFileAdapter (torrent.Files[i], p);
files[i] = p;
TorrentService.Bus.Register (p, adapter);
}
}
开发者ID:jackgao,项目名称:bitsharp-dbus,代码行数:15,代码来源:TorrentAdapter.cs
示例19: StartUp
public void StartUp()
{
DateTime current = new DateTime(2006, 7, 1, 5, 5, 5);
DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0);
TimeSpan span = current - epochStart;
creationTime = (long)span.TotalSeconds;
Console.WriteLine(creationTime.ToString() + "Creation seconds");
BEncodedDictionary torrentInfo = new BEncodedDictionary();
torrentInfo.Add("announce", new BEncodedString("http://myannouceurl/announce"));
torrentInfo.Add("creation date", new BEncodedNumber(creationTime));
torrentInfo.Add("nodes", new BEncodedList()); //FIXME: What is this?
torrentInfo.Add("comment.utf-8", new BEncodedString("my big long comment"));
torrentInfo.Add("comment", new BEncodedString("my big long comment"));
torrentInfo.Add("azureus_properties", new BEncodedDictionary()); //FIXME: What is this?
torrentInfo.Add("created by", new BEncodedString("MonoTorrent/" + VersionInfo.ClientVersion));
torrentInfo.Add("encoding", new BEncodedString("UTF-8"));
torrentInfo.Add("info", CreateInfoDict());
torrentInfo.Add("private", new BEncodedString("1"));
torrent = Torrent.Load(torrentInfo);
}
开发者ID:Cyarix,项目名称:monotorrent,代码行数:21,代码来源:TorrentTest.cs
示例20: AddTorrent
public void AddTorrent(Torrent torrent, string path, bool suppressMessages = false)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var wrapper = new TorrentWrapper(torrent, path, new TorrentSettings());
if (Client.Torrents.Any(t => t.Torrent.InfoHash == wrapper.InfoHash))
{
if (!suppressMessages)
MessageBox.Show(torrent.Name + " has already been added.", "Error");
return;
}
var periodic = Client.AddTorrent(wrapper);
// Save torrent to cache
var cache = Path.Combine(SettingsManager.TorrentCachePath, Path.GetFileName(torrent.TorrentPath));
if (File.Exists(cache))
File.Delete(cache);
File.Copy(torrent.TorrentPath, cache);
File.WriteAllText(Path.Combine(Path.GetDirectoryName(cache),
Path.GetFileNameWithoutExtension(cache)) + ".info", path);
periodic.CacheFilePath = cache;
}
开发者ID:headdetect,项目名称:Patchy,代码行数:21,代码来源:MainWindow.Logic.cs
注:本文中的Torrent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论