public static void Serialize(object o, TextWriter w) { if (EnableJsonSerializer) { // TODO - enable JSON serializer throw new Exception("JSON serializer isn't configured"); } else { LegacySerializer.Serialize(o, w, typeof(object)); } }
public static string SerializeToString(object o) { if (EnableJsonSerializer) { // warning disabled because code waits for the TODO - enable JSON serializer #pragma warning disable CS0162 // Unreachable code detected var js = new JsonSerializer(); return(js.SerializeToString(o)); #pragma warning restore CS0162 // Unreachable code detected } else { var sw = new StringWriter(); LegacySerializer.Serialize(o, sw, typeof(object)); return(sw.ToString()); } }