public virtual T From <T>(string json) { try { return(JsonConvert.DeserializeObject <T>(json)); } catch { return(SerializerHelper.Default <T>()); } }
public virtual string To <T>(T graph) { try { return(JsonConvert.SerializeObject(graph, Formatting.Indented)); } catch { return(SerializerHelper.Default()); } }
public virtual T From <T>(string toml) { try { return(Toml.ReadString <T>(toml)); } catch { return(SerializerHelper.Default <T>()); } }
public virtual string To <T>(T graph) { try { return(Toml.WriteString(graph)); } catch { return(SerializerHelper.Default()); } }
public virtual string To <T>(T graph) { try { var sw = new StringWriter(); this._serializer.Serialize(sw, graph); return(sw.ToString()); } catch { return(SerializerHelper.Default()); } }
public virtual T From <T>(string yaml) { try { var sr = new StringReader(yaml); var result = this._deserializer.Deserialize <T>(sr); return(result); } catch { return(SerializerHelper.Default <T>()); } }
public virtual string To <T>(T graph) { try { var ser = new XmlSerializer(typeof(T)); var writer = new StringWriter(); ser.Serialize(writer, graph); return(writer.ToString()); } catch { return(SerializerHelper.Default()); } }
public virtual T From <T>(string xml) { var xdoc = new XmlDocument(); try { xdoc.LoadXml(xml); var reader = new XmlNodeReader(xdoc.DocumentElement); var ser = new XmlSerializer(typeof(T)); var graph = (T)ser.Deserialize(reader); return(graph); } catch { return(SerializerHelper.Default <T>()); } }