예제 #1
0
 public static object ReadData(string file, Type t)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(t);
         FileStream    fs         = new FileStream(file, FileMode.Open);
         return(serializer.Deserialize(fs));
     }
     catch (Exception ex)
     {
         SeraLogger.SeralizerFailed(file, ex);
         return(null);
     }
 }
예제 #2
0
 public static void WriteData(string file, object dataToSave)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(dataToSave.GetType());
         TextWriter    writer     = new StreamWriter(file);
         serializer.Serialize(writer, dataToSave);
         writer.Close();
     }
     catch (Exception ex)
     {
         SeraLogger.SeralizerFailed(file, ex);
     }
 }