/// <summary>
 /// Finds a TorrentManager with specific TorrentHash
 /// </summary>
 /// <param name="hash"></param>
 /// <returns></returns>
 private TorrentManager FindTorrentByHash(TorrentHash hash)
 {
     return (from t in _torrents
             where t.InfoHash.ToHex() == hash.ToString()
             select t).SingleOrDefault();
 }
        /// <summary>
        /// Removes a torrent from a client with specific hash
        /// </summary>
        /// <param name="hash"></param>
        public void RemoveTorrent(TorrentHash hash)
        {
            var torrentManager = FindTorrentByHash(hash);

            if (torrentManager != null)
            {
                TorrentData data = (from d in _torrentData
                                   where d.Hash.ToString() == torrentManager.InfoHash.ToHex()
                                   select d).SingleOrDefault();
                _torrentData.Remove(data);
                torrentManager.Stop();
                _engine.Unregister(torrentManager);
                _torrents.Remove(torrentManager);

                if (File.Exists(torrentManager.Torrent.TorrentPath))
                    File.Delete(torrentManager.Torrent.TorrentPath);
            }
        }
 /// <summary>
 /// Stops a torrent with specific hash
 /// </summary>
 /// <param name="hash"></param>
 public void StopTorrent(TorrentHash hash)
 {
     var torrentManager = FindTorrentByHash(hash);
     if (torrentManager != null)
         torrentManager.Stop();
 }
 /// <summary>
 /// Pauses a torrent with specific hash
 /// </summary>
 /// <param name="hash"></param>
 public void PauseTorrent(TorrentHash hash)
 {
     var torrentManager = FindTorrentByHash(hash);
     if (torrentManager != null)
         torrentManager.Pause();
 }