public static string WriteToString(this DataTable table, StiDataFormatType type) { if (type == StiDataFormatType.Xml) { return(table.WriteToString()); } if (type == StiDataFormatType.Json && table.Rows.Count == 0) { var columns = new List <StiDataColumnSchema>(); foreach (DataColumn dataColumn in table.Columns) { columns.Add(new StiDataColumnSchema(dataColumn.ColumnName, dataColumn.DataType)); } return(JsonConvert.SerializeObject(columns)); } return(table.WriteToJson()); }
public static DataTable ReadFrom(StiDataFormatType type, string str) { return(type == StiDataFormatType.Json ? ReadFromJson(str) : ReadFromString(str)); }