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); }
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); }