Exemple #1
0
        private byte[] LoadXmlFileAsWBXML(string filePath)
        {
            var xml = LoadXmlFile(filePath);

            var encoder = new ASWBXML();

            encoder.LoadXml(xml);
            return(encoder.GetBytes());
        }
Exemple #2
0
 // This function uses the ASWBXML class to encode
 // XML into a WBXML stream.
 private byte[] EncodeXMLString(string xmlString)
 {
     try
     {
         ASWBXML encoder = new ASWBXML();
         encoder.LoadXml(xmlString);
         return(encoder.GetBytes());
     }
     catch (Exception ex)
     {
         ASError.ReportException(ex);
         return(null);
     }
 }
Exemple #3
0
 // This function uses the ASWBXML class to decode
 // a WBXML stream into XML.
 private string DecodeWBXML(byte[] wbxml)
 {
     try
     {
         ASWBXML decoder = new ASWBXML();
         decoder.LoadBytes(wbxml);
         return(decoder.GetXml());
     }
     catch (Exception ex)
     {
         ASError.ReportException(ex);
         return("");
     }
 }
Exemple #4
0
 internal static byte[] Encode(string stringXML)
 {
     try
     {
         ASWBXML encoder = new ASWBXML();
         encoder.LoadXml(stringXML);
         return(encoder.GetBytes());
     }
     catch (Exception ex)
     {
         LogService.Log("ASXML", "Failed to encode content: " + ex.Message);
         throw;
     }
 }
Exemple #5
0
        /*
         * public ASCommandResponse(HttpWebResponse httpResponse)
         * {
         *  Stream responseStream = httpResponse.GetResponseStream();
         *  List<byte> bytes = new List<byte>();
         *  byte[] byteBuffer = new byte[256];
         *  int count = 0;
         *
         *  count = responseStream.Read(byteBuffer, 0, 256);
         *  while (count > 0)
         *  {
         *      bytes.AddRange(byteBuffer);
         *
         *      if (count < 256)
         *      {
         *          int excess = 256 - count;
         *          bytes.RemoveRange(bytes.Count - excess, excess);
         *      }
         *
         *      count = responseStream.Read(byteBuffer, 0, 256);
         *  }
         *
         *  wbxmlBytes = bytes.ToArray();
         *
         *  DecodeWBXML(wbxmlBytes);
         * }
         */

        public ASCommandResponse(byte[] wbxml)
        {
            wbxmlBytes = wbxml;

            ASWBXML decoder = new ASWBXML();

            if (wbxml.Length > 0)
            {
                // Decode without smart view parsing
                decoder.LoadBytes(wbxml);
                xmlString = decoder.GetXml();

                // Decode with smart view parsing
                decoder.LoadBytes(wbxml, true);
                XmlDoc = decoder.GetXmlDoc();
            }
        }
        private string DecodeWBXML(byte[] wbxml)
        {
            try
            {
                ASWBXML decoder = new ASWBXML();


                decoder.LoadBytes(wbxml);
                return(decoder.GetXml());
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error calling DecodeWBXML");
                //VSError.ReportException(ex);
                return("");
            }
        }
Exemple #7
0
 internal static string Decode(byte[] wbxml)
 {
     if (wbxml == null || wbxml.Length == 0)
     {
         return(string.Empty);
     }
     try
     {
         ASWBXML decoder = new ASWBXML();
         decoder.LoadBytes(wbxml);
         return(decoder.GetXml());
     }
     catch (Exception ex)
     {
         LogService.Log("ASXML", "Failed to decode content: " + ex.Message);
         throw;
     }
 }
Exemple #8
0
 private byte[] EncodeXMLString(string stringXML)
 {
     try
     {
         ASWBXML encoder = new ASWBXML();
         encoder.LoadXml(stringXML);
         return(encoder.GetBytes());
     }
     catch (Exception ex)
     {
         //VSError.ReportException(ex);
         MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error");
         System.Diagnostics.Debug.WriteLine("--------------------------");
         System.Diagnostics.Debug.WriteLine("Exception:");
         System.Diagnostics.Debug.WriteLine("  Message: " + ex.Message);
         System.Diagnostics.Debug.WriteLine("    Stack: " + ex.StackTrace);
         return(null);
     }
 }
Exemple #9
0
 private string DecodeWBXML(byte[] wbxml)
 {
     try
     {
         ASWBXML decoder = new ASWBXML();
         decoder.LoadBytes(wbxml);
         return(decoder.GetXml());
     }
     catch (Exception ex)
     {
         //VSError.ReportException(ex);
         MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error");
         System.Diagnostics.Debug.WriteLine("--------------------------");
         System.Diagnostics.Debug.WriteLine("Exception:");
         System.Diagnostics.Debug.WriteLine("  Message: " + ex.Message);
         System.Diagnostics.Debug.WriteLine("    Stack: " + ex.StackTrace);
         return("");
     }
 }