public void Test1() { /*tInt = new SharpTorrent.BitTorrentProtocol.BeEncode.String(); tInt.Set(-13); Console.WriteLine(tInt.ToString()); tInt = new SharpTorrent.BitTorrentProtocol.BeEncode.String("-13"); Console.WriteLine(tInt.ToString()); tInt = new SharpTorrent.BitTorrentProtocol.BeEncode.String("Hola pueblo"); Console.WriteLine(tInt.ToString());*/ Dictionary dic = new Dictionary(); List lista = new List(3); lista.Add(new SharpTorrent.BitTorrentProtocol.BeEncode.String("Preciosa")); lista.Add(new SharpTorrent.BitTorrentProtocol.BeEncode.String("amable")); lista.Add(new Integer(10)); dic.Add("miriam", lista); byte[] bee = dic.BeEncode(); Console.ReadLine(); }
public File(List fileList, int numPieces) : this(numPieces) { numFiles = 0; CreateFileStruct(); }
private BeEncode.List ParseList(byte [] buffer) { List pList = new List(); // Check the List if ((buffer[actualTokenPos] != (char)'l') || (buffer[actualTokenPos + 1] == (char)'e')) throw new BePaserException("There is not a valid List at position " + actualTokenPos.ToString()); // Remove the 'l' actualTokenPos++; // In the List we can found a Integer, a String, a List or a Dictionary. while (buffer[actualTokenPos] != (char)'e') { switch (buffer[actualTokenPos]) { case (byte) 'd': pList.Add(ParseDictionary(buffer)); break; case (byte)'l': pList.Add(ParseList(buffer)); break; case (byte)'i': pList.Add(ParseInteger(buffer)); break; default: pList.Add(ParseString(buffer)); break; } } // We have the list, remove the 'e' actualTokenPos++; return pList; }