private static string GetNodeText(MsgPackReader reader) { if (reader.IsArray) { return(String.Format("Array ({0} items)", reader.ChildObjectCount)); } if (reader.IsMap) { return(String.Format("Map ({0} items)", reader.ChildObjectCount / 2)); } var value = reader.GetValue(); if (value == null) { return("null"); } var stringValue = value as string; if (stringValue != null) { return("\"" + stringValue.Replace("\"", "\\\"").Replace("\0", "\\0") + "\""); } var byteValue = value as byte[]; if (byteValue != null) { return(GetHex(byteValue)); } return(value.ToString()); }
private static string GetNodeText(MsgPackReader reader) { if (reader.IsArray) return String.Format("Array ({0} items)", reader.ChildObjectCount); if (reader.IsMap) return String.Format("Map ({0} items)", reader.ChildObjectCount/2); var value = reader.GetValue(); if (value == null) return "null"; var stringValue = value as string; if (stringValue != null) return "\"" + stringValue.Replace("\"", "\\\"").Replace("\0", "\\0") + "\""; var byteValue = value as byte[]; if (byteValue != null) return GetHex(byteValue); return value.ToString(); }