private TorrentInfo Load(Stream torrentStream) { try { InnerDictionary = (IBencodingDictionary)Bencoding.Parse(torrentStream); var info = InnerDictionary.Value["info"] as IBencodingDictionary; isMFile = true; if (info.ContainsKey("files")) { var files = info.Value["files"].Value as IBencodingObject[]; _files.AddRange( files.Cast <IBencodingDictionary>() .Select(z => new TorrentFileInfo( (z.Value["path"].Value as IBencodingObject[]) .Cast <IBencodingObject <string> >().Select(x => x.Value).ToArray(), (long)z.Value["length"].Value))); } else { _files.Add(new TorrentFileInfo(new string[] { (string)info.Value["name"].Value }, (long)info.Value["length"].Value)); } } catch (Exception) { throw new ArgumentException("error torrent file"); } return(this); }
private TorrentInfo Load(Stream torrentStream) { try { InnerDictionary = (IBencodingDictionary)Bencoding.Parse(torrentStream); var info = InnerDictionary.Value["info"] as IBencodingDictionary; isMFile = true; if (info.ContainsKey("files")) { var files = info.Value["files"].Value as IBencodingObject[]; _files.AddRange( files.Cast<IBencodingDictionary>() .Select(z => new TorrentFileInfo( (z.Value["path"].Value as IBencodingObject[]) .Cast<IBencodingObject<string>>().Select(x => x.Value).ToArray(), (long)z.Value["length"].Value))); } else { _files.Add(new TorrentFileInfo(new string[] { (string)info.Value["name"].Value }, (long)info.Value["length"].Value)); } } catch (Exception) { throw new ArgumentException("error torrent file"); } return this; }