private void ParseSession(BDictionary contents, Torrent newTorrent, string sessionPath)
        {
            string piecesState = standardParser.Parse <BString>(contents.First().Value.EncodeAsBytes()).ToString();
            var    sharedFile  = new DownloadingFile(this, newTorrent, piecesState, sessionPath);

            filesList.AddLast(sharedFile);
        }
Ejemplo n.º 2
0
        public void TestDecodeBDictionary()
        {
            IBElement[] result = BencodeDecoder.Decode("d5:itemsli45e28:aBCdefghijklmnopqrstuvwxyz12ee");
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Length);
            Assert.IsNotNull(result[0]);
            Assert.IsInstanceOfType(result[0], typeof(BDictionary));
            BDictionary dict = (BDictionary)result[0];

            Assert.AreEqual(1, dict.Count);

            var item = dict.First();

            Assert.IsNotNull(item);

            BString key = item.Key;

            Assert.IsNotNull(key);
            Assert.AreEqual("items", key.Value);

            Assert.IsNotNull(item.Value);
            Assert.IsInstanceOfType(item.Value, typeof(BList));
            BList list = (BList)item.Value;

            Assert.AreEqual(2, list.Count);

            Assert.IsNotNull(list[0]);
            Assert.IsInstanceOfType(list[0], typeof(BInteger));
            BInteger integer = (BInteger)list[0];

            Assert.AreEqual(45L, integer.Value);

            Assert.IsNotNull(list[1]);
            Assert.IsInstanceOfType(list[1], typeof(BString));
            BString str = (BString)list[1];

            Assert.AreEqual("aBCdefghijklmnopqrstuvwxyz12", str.Value);
        }