Example #1
0
 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);
 }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
0
 public static T FromCsv <T>(this string csv)
 {
     return(CsvSerializer.DeserializeFromString <T>(csv));
 }
Example #5
0
 public static string ToCsv <T>(this T obj)
 {
     return(CsvSerializer.SerializeToString(obj));
 }