예제 #1
0
 public virtual T From <T>(string json)
 {
     try
     {
         return(JsonConvert.DeserializeObject <T>(json));
     }
     catch
     {
         return(SerializerHelper.Default <T>());
     }
 }
예제 #2
0
 public virtual string To <T>(T graph)
 {
     try
     {
         return(JsonConvert.SerializeObject(graph, Formatting.Indented));
     }
     catch
     {
         return(SerializerHelper.Default());
     }
 }
예제 #3
0
 public virtual T From <T>(string toml)
 {
     try
     {
         return(Toml.ReadString <T>(toml));
     }
     catch
     {
         return(SerializerHelper.Default <T>());
     }
 }
예제 #4
0
 public virtual string To <T>(T graph)
 {
     try
     {
         return(Toml.WriteString(graph));
     }
     catch
     {
         return(SerializerHelper.Default());
     }
 }
예제 #5
0
 public virtual string To <T>(T graph)
 {
     try
     {
         var sw = new StringWriter();
         this._serializer.Serialize(sw, graph);
         return(sw.ToString());
     }
     catch
     {
         return(SerializerHelper.Default());
     }
 }
예제 #6
0
 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>());
     }
 }
예제 #7
0
 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());
     }
 }
예제 #8
0
        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>());
            }
        }