public String getString(string lineprefix, object o) { if (o is Dictionary <string, object> ) { string s = "\n" + lineprefix + "{"; foreach (KeyValuePair <string, object> p in (Dictionary <string, object>)o) { s += "\n" + lineprefix + "\t" + p.Key + ":" + getString(lineprefix + "\t", p.Value) + ","; } s += "\n" + lineprefix + "}"; return(s); } if (o is List <object> ) { string s = "["; foreach (object a in (List <object>)o) { s += getString(lineprefix, a); s += ","; } s = s.TrimEnd(',') + "]"; return(s); } if (o is byte[]) { return("(" + ReadableBinary.CreateHexEditorString((byte[])o) + ")"); } return(o.ToString()); }
public string getString(string lineprefix, object o) { if (o == null) { return("null"); } if (o is Dictionary <string, object> ) { StringBuilder buf = new StringBuilder(); buf.Append(string.Concat("\n", lineprefix, "{")); foreach (KeyValuePair <string, object> p in (Dictionary <string, object>)o) { buf.AppendLine(string.Format("\n{0}\t{1}:{2},", lineprefix, p.Key, getString(lineprefix + "\t", p.Value))); } buf.Append(lineprefix + "}"); return(buf.ToString()); } if (o is List <object> ) { StringBuilder buf = new StringBuilder(); buf.Append("["); foreach (object a in (List <object>)o) { buf.Append(getString(lineprefix, a)).Append(","); } buf.Remove(buf.Length - 1, 1); buf.Append("]"); return(buf.ToString()); } if (o is byte[]) { return("(" + ReadableBinary.CreateHexEditorString((byte[])o) + ")"); } return(o.ToString()); }