Ejemplo n.º 1
0
        // Token: 0x06001895 RID: 6293 RVA: 0x00091804 File Offset: 0x0008FA04
        public XmlDocument ReadXmlDocument()
        {
            this.ReadHeader();
            XmlDocument result;

            try
            {
                bool   flag;
                bool   flag2;
                int    tag       = this.ReadTag(out flag, out flag2);
                string name      = WbxmlBase.Schema.GetName(tag);
                string nameSpace = WbxmlBase.Schema.GetNameSpace(tag);
                if (name == null || nameSpace == null)
                {
                    result = WbxmlReader.ErrorDocument;
                }
                else
                {
                    XmlDocument xmlDocument = new SafeXmlDocument();
                    bool        flag3       = WbxmlBase.Schema.IsTagSecure(tag);
                    bool        flag4       = WbxmlBase.Schema.IsTagAnOpaqueBlob(tag);
                    XmlElement  xmlElement;
                    if (flag3)
                    {
                        xmlElement = new AirSyncSecureStringXmlNode(null, name, nameSpace, xmlDocument);
                    }
                    else if (flag4)
                    {
                        xmlElement = new AirSyncBlobXmlNode(null, name, nameSpace, xmlDocument);
                    }
                    else
                    {
                        xmlElement = xmlDocument.CreateElement(name, nameSpace);
                    }
                    xmlDocument.AppendChild(xmlElement);
                    if (flag)
                    {
                        this.SkipAttributes();
                    }
                    if (flag2 && !this.FillXmlElement(xmlElement, 0, flag3, flag4))
                    {
                        result = WbxmlReader.ErrorDocument;
                    }
                    else
                    {
                        result = xmlDocument;
                    }
                }
            }
            catch (IndexOutOfRangeException innerException)
            {
                throw new WbxmlException("Invalid WBXML code/codepage from client", innerException);
            }
            catch (NotImplementedException innerException2)
            {
                throw new WbxmlException("Invalid WBXML data from client (see inner exception).", innerException2);
            }
            catch (ArgumentOutOfRangeException innerException3)
            {
                throw new WbxmlException("Invalid WBXML code from client", innerException3);
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x060018C8 RID: 6344 RVA: 0x00092888 File Offset: 0x00090A88
        private void WriteXmlElement(XmlElement elem)
        {
            int  tag  = WbxmlBase.Schema.GetTag(elem.NamespaceURI, elem.LocalName);
            bool flag = WbxmlWriter.ElementHasContent(elem);

            this.WriteTag(tag, flag, false);
            if (flag)
            {
                foreach (object obj in elem.ChildNodes)
                {
                    XmlNode xmlNode = (XmlNode)obj;
                    switch (xmlNode.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode as AirSyncBlobXmlNode;
                        if (airSyncBlobXmlNode != null)
                        {
                            int tag2 = WbxmlBase.Schema.GetTag(airSyncBlobXmlNode.NamespaceURI, airSyncBlobXmlNode.LocalName);
                            this.WriteTag(tag2, true, false);
                            if (airSyncBlobXmlNode.ByteArray != null)
                            {
                                this.WriteByteArray(airSyncBlobXmlNode.ByteArray);
                            }
                            if (airSyncBlobXmlNode.Stream != null)
                            {
                                switch (airSyncBlobXmlNode.OriginalNodeType)
                                {
                                case XmlNodeType.Text:
                                    this.stream.WriteByte(3);
                                    break;

                                case XmlNodeType.CDATA:
                                    this.stream.WriteByte(195);
                                    this.WriteMultiByteInteger((int)airSyncBlobXmlNode.StreamDataSize);
                                    break;
                                }
                                airSyncBlobXmlNode.CopyStream(this.stream);
                                if (airSyncBlobXmlNode.OriginalNodeType == XmlNodeType.Text)
                                {
                                    this.stream.WriteByte(0);
                                }
                            }
                            this.WriteEndTag();
                        }
                        else
                        {
                            this.WriteXmlElement((XmlElement)xmlNode);
                        }
                        break;
                    }

                    case XmlNodeType.Attribute:
                        break;

                    case XmlNodeType.Text:
                        this.WriteString(xmlNode.Value);
                        break;

                    case XmlNodeType.CDATA:
                        this.WriteOpaqueString(xmlNode.Value);
                        break;

                    default:
                        throw new AirSyncPermanentException(false);
                    }
                }
                this.WriteEndTag();
            }
        }
Ejemplo n.º 3
0
 // Token: 0x0600189B RID: 6299 RVA: 0x00091A14 File Offset: 0x0008FC14
 private bool FillXmlElement(XmlElement elem, int depth, bool elemIsSecureData, bool elemIsBlobData)
 {
     if (depth > 20)
     {
         throw new WbxmlException("Document nested too deep");
     }
     for (;;)
     {
         bool flag;
         bool flag2;
         int  num = this.ReadTag(out flag, out flag2);
         if (num == 1)
         {
             return(true);
         }
         if (num == 3)
         {
             if (elemIsSecureData)
             {
                 AirSyncSecureStringXmlNode airSyncSecureStringXmlNode = (AirSyncSecureStringXmlNode)elem;
                 airSyncSecureStringXmlNode.SecureData = this.ReadInlineSecureString();
             }
             else
             {
                 string innerText = this.ReadInlineString();
                 elem.InnerText = innerText;
             }
         }
         else if (num == 195)
         {
             if (elemIsSecureData)
             {
                 AirSyncSecureStringXmlNode airSyncSecureStringXmlNode2 = (AirSyncSecureStringXmlNode)elem;
                 airSyncSecureStringXmlNode2.SecureData = this.ReadOpaqueSecureString();
             }
             else if (elemIsBlobData)
             {
                 AirSyncBlobXmlNode airSyncBlobXmlNode = elem as AirSyncBlobXmlNode;
                 int num2 = this.ReadMultiByteInteger();
                 if (this.stream.Position + (long)num2 > this.stream.Length)
                 {
                     break;
                 }
                 if (this.parseBlobAsByteArray)
                 {
                     airSyncBlobXmlNode.ByteArray = this.ReadBytes(num2);
                 }
                 else
                 {
                     airSyncBlobXmlNode.Stream = new SubStream(this.underlyingStream, this.stream.Position, (long)num2);
                     this.stream.Seek((long)num2, SeekOrigin.Current);
                 }
             }
             else
             {
                 string innerText2 = this.ReadOpaqueString();
                 elem.InnerText = innerText2;
             }
         }
         if ((num & 63) >= 5)
         {
             if (flag)
             {
                 this.SkipAttributes();
             }
             string name      = WbxmlBase.Schema.GetName(num);
             string nameSpace = WbxmlBase.Schema.GetNameSpace(num);
             if (name == null || nameSpace == null)
             {
                 return(false);
             }
             bool       flag3 = WbxmlBase.Schema.IsTagSecure(num);
             bool       flag4 = WbxmlBase.Schema.IsTagAnOpaqueBlob(num);
             XmlElement xmlElement;
             if (flag3)
             {
                 xmlElement = new AirSyncSecureStringXmlNode(null, name, nameSpace, elem.OwnerDocument);
             }
             else if (flag4)
             {
                 xmlElement = new AirSyncBlobXmlNode(null, name, nameSpace, elem.OwnerDocument);
             }
             else
             {
                 xmlElement = elem.OwnerDocument.CreateElement(name, nameSpace);
             }
             if (flag2 && !this.FillXmlElement(xmlElement, depth + 1, flag3, flag4))
             {
                 return(false);
             }
             elem.AppendChild(xmlElement);
         }
     }
     return(false);
 }