string RenderValue(string s, QueryColumnInfo info) { bool putInQuotes = false; if (includeNulls && s == null) { s = "null"; } else { if (s == null) { s = ""; } if (removeTime && info.dataType == typeof(DateTime)) { int at = s.IndexOf(" "); if (at > 0) { s = s.Substring(0, at); } } if (removeNonAscii) { s = Regex.Replace(s, @"[^\u0000-\u007F]+", string.Empty); } if (removeNewLines) { s = s.Replace("\r\n", " "); s = s.Replace("\n", " "); s = s.Replace("\r", " "); } if (removeManySpaces) { s = s.Replace(" ", " "); } if (escapeWhenNecessary) { // https://www.csvreader.com/csv_format.php s = s.Replace("\"", "\"\""); if (s.Contains(",")) { putInQuotes = true; } if (s.Contains("\n")) { putInQuotes = true; } } if (info.dataType == typeof(string)) { if (putStringColumnsInDoubleQuotes) { putInQuotes = true; } if (putStringColumnsInDoubleQuotes) { putInQuotes = true; } } if (padStrings) { s = s.PadRight(info.maxLength); } if (putInQuotes) { s = quoteChar + s + quoteChar; } } if (format.IsOneOf("JSON Array", "JSON Object")) { s = QObject.GetValueForJson(info.dataType, s); if (format == "JSON Object") { s = "\"" + info.label + "\":" + s; } } else if (format == "SQL Insert") { s = QObject.GetValueForSql(info.dataType, s); } else if (format == "C# Object" || format == "C# Array") { s = QObject.GetValueForCSharp(info.dataType, s); if (format == "C# Object") { s = info.label + " = " + s; } } if (columnTemplate != "") { Template t = new Template(columnTemplate); t.SetToken("COLUMN", s); s = t.Render(); } return(s); }