当前位置: 首页>>代码示例>>C#>>正文


C# Torrent类代码示例

本文整理汇总了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);
        }
开发者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


注:本文中的Torrent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。