Permalink
Browse files

Work on enums & value types

  • Loading branch information...
1 parent 6bcd62d commit 99d51ccfb7dd36e73406f545cc505fcc60953046 @pseabury committed Aug 6, 2012
Showing with 20 additions and 5 deletions.
  1. +6 −1 src/ServiceStack.Text/CsvWriter.cs
  2. +14 −4 src/ServiceStack.Text/JsConfig.cs
@@ -114,7 +114,10 @@ public static void WriteObject(TextWriter writer, object records)
public static void WriteObjectRow(TextWriter writer, object record)
{
- WriteRow(writer, (T)record);
+ if(typeof(T).IsValueType)
+ WriteRow (writer, null);
+ else
+ WriteRow(writer, (T)record);
}
public static void Write(TextWriter writer, IEnumerable<T> records)
@@ -175,6 +178,8 @@ public static void WriteRow(TextWriter writer, T row)
public static void WriteRow(TextWriter writer, IEnumerable<string> row)
{
+ if (row == null) return; //AOT
+
var ranOnce = false;
foreach (var field in row)
{
@@ -213,19 +213,29 @@ public static bool RegisterTypeForAot<T>()
bool ret = false;
try
{
- JsonAotConfig.Register<T>();
-
int i = 0;
if(JsvWriter<T>.WriteFn() != null && JsvReader<T>.GetParseFn() != null) i++;
+ if(JsvWriter.GetWriteFn(typeof(T)) != null && JsvReader.GetParseFn(typeof(T)) != null) i++;
+ //if(JsvTypeSerializer.Instance.GetWriteFn<T>() != null && JsvTypeSerializer.Instance.GetParseFn<T>() != null) i++;
+ //if(JsvTypeSerializer.Instance.GetWriteFn(typeof(T)) != null && JsvTypeSerializer.Instance.GetParseFn(typeof(T)) != null) i++;
if(JsonWriter<T>.WriteFn() != null && JsonReader<T>.GetParseFn() != null) i++;
- if(QueryStringWriter<Poco>.WriteFn() != null) i++;
+ if(JsonWriter.GetWriteFn(typeof(T)) != null && JsonReader.GetParseFn(typeof(T)) != null) i++;
+ //if(JsonTypeSerializer.Instance.GetWriteFn<T>() != null && JsonTypeSerializer.Instance.GetParseFn<T>() != null) i++;
+ //if(JsonTypeSerializer.Instance.GetWriteFn(typeof(T)) != null && JsonTypeSerializer.Instance.GetParseFn(typeof(T)) != null) i++;
+ if(QueryStringWriter<T>.WriteFn() != null) i++;
CsvSerializer<T>.WriteFn();
CsvSerializer<T>.WriteObject(null, null);
CsvWriter<T>.WriteObject(null, null);
CsvWriter<T>.WriteObjectRow(null, null);
+
+ if(!typeof(T).IsValueType)
+ JsonAotConfig.Register<T>();
+
ret = true;
- }catch(Exception){}
+ }catch(Exception e){
+ System.Diagnostics.Debug.WriteLine(e.Message);
+ }
return ret;
}

0 comments on commit 99d51cc

Please sign in to comment.