Example #1
0
 public static DFUnpack ParseXml(string xml)
 {
     try
     {
         XmlSerializer xr      = new XmlSerializer(typeof(DFUnpack));
         TextReader    tr      = new StringReader(xml);
         DFUnpack      darkxml = (DFUnpack)xr.Deserialize(tr);
         if (darkxml.InstallId < 1000000 || darkxml.InstallId > 9999999)
         {
             throw new XmlException("Invalid DFUnpack.InstallId");
         }
         if (darkxml.Filename == null)
         {
             throw new XmlException("Invalid DFUnpack.Filename");
         }
         if (darkxml.InstallPath == null)
         {
             throw new XmlException("Invalid DFUnpack.InstallPath");
         }
         if (darkxml.DFPath == null)
         {
             throw new XmlException("Invalid DFUnpack.DFPath");
         }
         return(darkxml);
     }
     catch (Exception e)
     {
         Debug.WriteLine("Exception: " + e.Message);
         Application.Current.Shutdown(ExitCode.InvalidXml);
         return(null);
     }
 }
Example #2
0
 public static string ToString(DFUnpack xml)
 {
     try
     {
         XmlSerializer xr = new XmlSerializer(typeof(DFUnpack));
         TextWriter    tw = new StringWriter();
         xr.Serialize(tw, xml);
         return(tw.ToString().Replace("\"", "\\\""));
     }
     catch (Exception e)
     {
         Debug.WriteLine("Exception: " + e.Message);
         Application.Current.Shutdown(ExitCode.InvalidXml);
         return(null);
     }
 }