コード例 #1
0
 public static void XMLSerialize(String filename, ActorData arg)
 {
     try
     {
         filename = Store.BaseDirection + filename;
         XmlSerializer serializer = null;
         FileStream    stream     = null;
         serializer = new XmlSerializer(typeof(ActorData));
         stream     = new FileStream(filename, FileMode.Create, FileAccess.Write);
         serializer.Serialize(stream, arg);
         if (stream != null)
         {
             stream.Close();
         }
     }
     catch (Exception ex)
     {
         Logging.LogManager.DefaultLogger.Error(ex.Message);
         Logging.LogManager.DefaultLogger.Error(ex.InnerException.Message);
     }
 }
コード例 #2
0
        public static ActorData XMLDeserialize(String filename)
        {
            try
            {
                filename = Store.BaseDirection + filename;
                XmlSerializer serializer = null;
                FileStream    stream     = null;
                ActorData     emp        = new ActorData();
                serializer = new XmlSerializer(typeof(ActorData));
                stream     = new FileStream(filename, FileMode.Open);
                emp        = (ActorData)serializer.Deserialize(stream);
                if (stream != null)
                {
                    stream.Close();
                }

                return(emp);
            }
            catch (Exception ex)
            {
                Logging.LogManager.DefaultLogger.Error(ex.Message);
                return(null);
            }
        }