public static object Deserialize(Stream str) { try { // TODO - enable JSON serializer IsDeserializing = true; var result = LegacySerializer.Deserialize <object>(str); IsDeserializing = false; return(result); } catch (JsonException ex) { Console.Error.WriteLine("Could not deserialize using JSON serializer. Attempting to use legacy serializer. Error dump follows:"); Console.Error.WriteLine(ex); try { return(LegacySerializer.Deserialize <object>(str)); } catch (SerializationException ex2) { Console.Error.WriteLine("Could not deserialize using legacy serializer. Error dump follows:"); Console.Error.WriteLine(ex2); } throw new Exception("Unable to deserialize. Please check stderr.txt for details."); } }
public static object DeserializeFromString(string s) { 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.DeserializeFromString(s)); #pragma warning restore CS0162 // Unreachable code detected } else { IsDeserializing = true; var sr = new StringReader(s); var result = LegacySerializer.Deserialize <object>(sr); IsDeserializing = false; return(result); } }
internal static T Deserialize <T>(TextReader r, ObjectGraphContext context = null) { return((T)LegacySerializer.Deserialize(r, typeof(T), true, context)); }