public static void SerializeToWriter <T>(T value, TextWriter writer) { if (value == null) { return; } if (typeof(T) == typeof(string)) { writer.Write(value); return; } CsvSerializer <T> .WriteObject(writer, value); }
public static string SerializeToString <T>(T value) { if (value == null) { return(null); } if (typeof(T) == typeof(string)) { return(value as string); } var writer = StringWriterThreadStatic.Allocate(); CsvSerializer <T> .WriteObject(writer, value); return(StringWriterThreadStatic.ReturnAndFree(writer)); }
public static void InitAot <T>() { CsvSerializer <T> .WriteFn(); CsvSerializer <T> .WriteObject(null, null); CsvWriter <T> .Write(null, default(IEnumerable <T>)); CsvWriter <T> .WriteRow(null, default(T)); CsvWriter <T> .WriteObject(null, default(IEnumerable <T>)); CsvWriter <T> .WriteObjectRow(null, default(IEnumerable <T>)); CsvReader <T> .ReadRow(null); CsvReader <T> .ReadObject(null); CsvReader <T> .ReadObjectRow(null); CsvReader <T> .ReadStringDictionary(null); }
public static T FromCsv <T>(this string csv) { return(CsvSerializer.DeserializeFromString <T>(csv)); }
public static string ToCsv <T>(this T obj) { return(CsvSerializer.SerializeToString(obj)); }