public string Bencode()
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            this.serialize(dictionary, null);
            Bencoding.BElement bencoded = bencode(dictionary);
            string             b        = bencoded.ToBencodedString();

            return(b);
        }
예제 #2
0
        public string Bencode()
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();
            var json = ser.Serialize(this);

            // Deserialize into a dictionary and remove
            // empty attributes
            var jsonDict = ser.Deserialize <Dictionary <string, object> >(json);

            removeEmptyFields(ref jsonDict);

            Bencoding.BElement bencoded = bencode(jsonDict);
            string             b        = bencoded.ToBencodedString();

            return(b);
        }