private TorrentDetails Convert(TorrentManager torrentManager) { var torrent = torrentManager.Torrent; var torrentDetails = new TorrentDetails { Id = torrent.InfoHash.ToString(), Name = torrent.Name, Files = torrent.Files.Select(f => f.Path).ToArray(), OutputDirectory = torrentManager.SavePath, Size = torrent.Size, Progress = torrentManager.Progress, DownloadBytesPerSecond = torrentManager.Monitor.DownloadSpeed, UploadBytesPerSecond = torrentManager.Monitor.UploadSpeed }; switch (torrentManager.State) { case TorrentState.Hashing: torrentDetails.Status = TorrentStatus.Hashing; break; case TorrentState.Downloading: case TorrentState.Stopping: case TorrentState.Metadata: torrentDetails.Status = TorrentStatus.Downloading; break; case TorrentState.Seeding: torrentDetails.Status = TorrentStatus.Seeding; break; case TorrentState.Stopped: case TorrentState.Paused: torrentDetails.Status = TorrentStatus.Stopped; break; case TorrentState.Error: torrentDetails.Status = TorrentStatus.Error; break; } return(torrentDetails); }
private TorrentDetails Convert(TorrentManager torrentManager) { var torrent = torrentManager.Torrent; var torrentDetails = new TorrentDetails { Id = torrent.InfoHash.ToString(), Name = torrent.Name, Files = torrent.Files.Select(f => f.Path).ToArray(), OutputDirectory = torrentManager.SavePath, Size = torrent.Size, Progress = torrentManager.Progress, DownloadBytesPerSecond = torrentManager.Monitor.DownloadSpeed, UploadBytesPerSecond = torrentManager.Monitor.UploadSpeed }; switch(torrentManager.State) { case TorrentState.Hashing: torrentDetails.Status = TorrentStatus.Hashing; break; case TorrentState.Downloading: case TorrentState.Stopping: case TorrentState.Metadata: torrentDetails.Status = TorrentStatus.Downloading; break; case TorrentState.Seeding: torrentDetails.Status = TorrentStatus.Seeding; break; case TorrentState.Stopped: case TorrentState.Paused: torrentDetails.Status = TorrentStatus.Stopped; break; case TorrentState.Error: torrentDetails.Status = TorrentStatus.Error; break; } return torrentDetails; }