Beispiel #1
0
 /// <summary>
 /// Seralize ClientRequestDO to XML.
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="xmlOutput"></param>
 /// <param name="requestDO"></param>
 public static void GenerateXML(string fileName, out string xmlOutput, ClientRequestDO requestDO = null)
 {
     xmlOutput = string.Empty;
     try
     {
         using (XmlWriter writer = XmlWriter.Create(fileName, new XmlWriterSettings()
         {
             Indent = true
         }))
         {
             if (requestDO == null)
             {
                 requestDO = activeRequest;
             }
             XmlSerializer serializer = new XmlSerializer(typeof(ClientRequestDO));
             serializer.Serialize(writer, requestDO);
             writer.Flush();
             writer.Close();
             activeRequest = null;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Function: GenerateXML: " + ex.Message);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Generate a new request.
 /// </summary>
 /// <returns></returns>
 public static bool NewRequest()
 {
     if (activeRequest == null)
     {
         activeRequest = new ClientRequestDO();
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        public static void Main(String[] args)
        {
            ClientRequestDO.NewRequest();
            ClientRequestDO.GetCurrentRequest().BuildFiles.Add("Program.cs");
            ClientRequestDO.GetCurrentRequest().TestDrivers.Add("TestDriver.cs");
            ClientRequestDO.GenerateXML("yo", out string xml, null);
            //  File saved.


            var reqDo = ClientRequestDO.GenerateClientRequestFromXML("File.xml");
            //  Reconstructed.
        }
Beispiel #4
0
 /// <summary>
 /// Reconstruct the ClientRequestDO object from XML file.
 /// </summary>
 /// <param name="xmlFileName"></param>
 /// <returns></returns>
 public static ClientRequestDO GenerateClientRequestFromXML(string xmlFileName)
 {
     try
     {
         ClientRequestDO requestDO = null;
         using (XmlReader reader = XmlReader.Create(xmlFileName))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(ClientRequestDO));
             requestDO = (ClientRequestDO)serializer.Deserialize(reader);
         }
         return(requestDO);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Function: GenerateClientRequestFromXML: " + ex.Message);
         return(null);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Cancel the current request.
 /// </summary>
 public static void CancelRequest()
 {
     activeRequest = null;
 }