Exemple #1
0
 public static void Serialize <T>(string xmlFilePath, T obj, bool overwrite = true)
 {
     using (var fileStream = FileStreamHelper.NewWrite(xmlFilePath, overwrite))
     {
         XmlStreamSerializer.Serialize(fileStream, obj);
     }
 }
Exemple #2
0
 public static T Deserialize <T>(string xmlFilePath)
 {
     using (var fileStream = FileStreamHelper.NewRead(xmlFilePath))
     {
         var output = XmlStreamSerializer.Deserialize <T>(fileStream);
         return(output);
     }
 }
Exemple #3
0
        /// <summary>
        /// Writes XML without any namespaces.
        /// </summary>
        public static void SerializeWithoutNamespaces <T>(Stream stream, T obj)
        {
            var xmlWriterSettings = XmlWriterSettingsHelper.GetIndent();

            XmlStreamSerializer.SerializeWithoutNamespaces(stream, obj, xmlWriterSettings);
        }