public static string SaveToString(DataFormat format, DataNode root) { switch (format) { case DataFormat.XML: return(XMLWriter.WriteToString(root)); case DataFormat.JSON: return(JSONWriter.WriteToString(root)); case DataFormat.YAML: return(YAMLWriter.WriteToString(root)); case DataFormat.CSV: return(CSVWriter.WriteToString(root)); default: { throw new System.Exception("Format not supported"); } } }