Ejemplo n.º 1
0
        /// <summary>
        /// Process response from server to establish SyncML models as a SyncMLSyncML object.
        /// The inherited function should call the base first, then analyze the model.
        /// If the response has fatal error, it is signaled through serverSyncML== null.
        /// </summary>
        /// <param name="text">True if success. If fail, ServerSyncML is null. </param>
        protected virtual bool ProcessResponse(string text)
        {
            Debug.WriteLine("ProcessResponse from server: " + text);

            try
            {
                ServerSyncML = SyncMLSyncML.Create(XElement.Parse(text));
            }
            catch (XmlException)
            {
                Trace.TraceInformation("The server returns no SyncML but this: " + text);
                Facade.DisplayOperationMessage("The connection fail. Please check the server URL.");
                ServerSyncML = null;
            }
            catch (ArgumentNullException)
            {
                Trace.TraceInformation("The server return invalid or incomplete SyncML message:" + text);
                ServerSyncML = null; // up to this point, SyncMLSyncML object has been created though elements are not right.
            }
            catch (Exception e)
            {
                Trace.TraceWarning("When ProcessResponse (General Exception caught): " + e.ToString());
                ServerSyncML = null; // serverSyncML might be created already.
            }

            if (ServerSyncML == null)
            {
                Facade.SoFarOK = false;
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        public void TestSyncML()
        {
            XElement nav = XElement.Load(CaseFile("SyncML.xml"));

            SyncMLSyncML f = SyncMLSyncML.Create(nav);

            Assert.IsTrue(CompareXml(nav, f.Xml), f.Xml.ToString());
        }