public override bool RemoveFromBoth(BDictionary <int, int> blist, List <IntPair> list, int item) { int i = blist.IndexOf(item); if (i == -1) { return(false); } blist.Remove(item); list.RemoveAt(i); return(true); }
private void BtnRemoveInvalidTorrentInfo_Click(object sender, EventArgs e) { if (utBDictionary == null) { MessageBox.Show("请先加载 resume.data 文件!"); return; } BString bpath = new BString("path"); BString blabel = new BString("label"); BString bcompleded = new BString("completed_on"); List <string> exceptedCatagoryList = new List <string> { "GGN", "OpenCD", "ORPHEUS", "Redacted" }; // 待删列表 List <BString> deleteList = new List <BString>(); foreach (KeyValuePair <BString, IBObject> kv in utBDictionary) { if (kv.Key.ToString().ToLower().EndsWith(".torrent")) { var tbd = kv.Value as BDictionary; if (exceptedCatagoryList.Contains(tbd[blabel].ToString())) { continue; } string tpath = tbd[bpath].ToString(); if (tbd[bcompleded].ToString() != "0") { if (!(Directory.Exists(tpath) || File.Exists(tpath))) { deleteList.Add(kv.Key); } } } } foreach (BString bKey in deleteList) { utBDictionary.Remove(bKey); } MessageBox.Show(string.Format( "完成,共删除{0}项", deleteList.Count), "提示", MessageBoxButtons.OK); }
public void Root_MissingInfoField_Strict_ThrowsInvalidTorrentException() { // Arrange ParsedData = ValidSingleFileTorrentData; ParsedData.Remove(TorrentFields.Info); // Act var parser = new TorrentParser(BencodeParser, TorrentParserMode.Strict); Action action = () => parser.Parse((BencodeReader)null); // Assert action.Should().Throw <InvalidTorrentException>() .Where(ex => ex.InvalidField == TorrentFields.Info); }