Example #1
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (!reader.ReadToFollowing("photos"))
            {
                throw new ResponseXmlException("Unable to find \"photos\" element in response.");
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "maxdisplaypx":
                    MaximumDisplayPixels = reader.ReadContentAsInt();
                    break;

                case "maxupload":
                    MaximumPhotoUpload = reader.ReadContentAsLong();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            if (!reader.ReadToFollowing("videos"))
            {
                throw new ResponseXmlException("Unable to find \"videos\" element in response.");
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "maxduration":
                    MaximumVideoDuration = reader.ReadContentAsInt();
                    break;

                case "maxupload":
                    MaximumVideoUpload = reader.ReadContentAsLong();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Skip();
        }
Example #2
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            XmlSerializer serializer;

            if (!reader.Read())
            {
                return;
            }

            reader.ReadStartElement("type");
            _type = (VariantType)reader.ReadContentAsInt();
            reader.ReadEndElement();

            reader.ReadStartElement("value");

            switch (_type)
            {
            case VariantType.Int:
                _valueInt = reader.ReadContentAsInt();
                break;

            case VariantType.Long:
                _valueLong = reader.ReadContentAsLong();
                break;

            case VariantType.ULong:
                _valueULong = (ulong)reader.ReadContentAsLong();
                break;

            case VariantType.Double:
                _valueDouble = (double)reader.ReadContentAsDouble();
                break;

            case VariantType.String:
                _valueString = reader.ReadContentAsString();
                break;

            case VariantType.ByteString:
                serializer      = new XmlSerializer(typeof(byte[]));
                _valueByteArray = (byte[])serializer.Deserialize(reader);
                break;

            case VariantType.BitStream:
                serializer      = new XmlSerializer(typeof(BitwiseStream));
                _valueBitStream = (BitwiseStream)serializer.Deserialize(reader);
                break;
            }

            reader.ReadEndElement();
        }
Example #3
0
        protected override CloudArgs AnalysisData(System.Xml.XmlReader reader)
        {
            if (_webClient.ResponseHeaders != null)
            {
                string date = _webClient.ResponseHeaders["Date"];
                if (date != null)
                {
                    DateTime serverTime = DateTime.Parse(date);
                    TimeInterval = DateTime.Now.Subtract(serverTime).Ticks;
                }
            }

            var args = new CloudArgs();

            args.Datas = new List <CloudDataInfo>();
            while (reader.Read())
            {
                if (reader.Name == "root")
                {
                    if (Method == HttpMethod.Get)
                    {
                        reader.MoveToAttribute("etag");
                        Etag = reader.ReadContentAsString();
                    }
                    reader.MoveToAttribute("ret");
                    int ret = reader.ReadContentAsInt();
                    reader.MoveToAttribute("msg");
                    string msg = reader.ReadContentAsString();
                    if (ret == 0)
                    {
                        args.message = msg;
                        return(args);
                    }
                }
                if (reader.Name == Type)
                {
                    while (reader.Read())
                    {
                        if (reader.Name == "Item")
                        {
                            try
                            {
                                var infoSync = new CloudDataInfo();

                                if (reader.MoveToAttribute("UUID"))
                                {
                                    infoSync.UUID = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("Device"))
                                {
                                    infoSync.Device = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("DeviceHistory"))
                                {
                                    infoSync.DeviceHistory = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Id"))
                                {
                                    infoSync.Id = reader.ReadContentAsInt();
                                }
                                //reader.MoveToAttribute("ClId");
                                //infoSync.ClId = reader.ReadContentAsInt();
                                if (reader.MoveToAttribute("Name"))
                                {
                                    infoSync.Name = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("SubName"))
                                {
                                    infoSync.SubName = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("SubId"))
                                {
                                    infoSync.SubId = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Pos"))
                                {
                                    infoSync.Pos = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Duration"))
                                {
                                    infoSync.Duration = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("ModifyTime"))
                                {
                                    infoSync.ModifyTime = reader.ReadContentAsLong();
                                }
                                //reader.MoveToAttribute("Property");
                                //infoSync.Property = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("VideoType");
                                //infoSync.VideoType = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("Bt");
                                //infoSync.Bt = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("Mode");
                                //infoSync.Mode = reader.ReadContentAsInt();
                                args.Datas.Add(infoSync);
                            }
                            catch { }
                        }
                    }
                }
            }
            return(args);
        }
Example #4
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToAttribute("ActionId");
     ActionId = reader.ReadContentAsInt();
     reader.MoveToAttribute("Success");
     Success = bool.Parse(reader.ReadContentAsString());
     reader.MoveToAttribute("AffectedRows");
     AffectedRows = reader.ReadContentAsInt();
     reader.MoveToAttribute("RowVersion");
     RowVersion = reader.ReadContentAsLong();
     reader.MoveToElement();
     reader.ReadStartElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("FailureMessage");
         FailureMessage = reader.ReadString();
         reader.ReadEndElement();
     }
     else
     {
         FailureMessage = null;
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Result");
         Result = reader.ReadContentAsObject();
         reader.ReadEndElement();
     }
     else
     {
         Result = null;
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Parameters", Namespaces.Data);
         var parameters = new List <PersistenceParameter>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "Parameter")
             {
                 var parameter = new PersistenceParameter();
                 ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                 parameters.Add(parameter);
             }
             else
             {
                 reader.Skip();
             }
         }
         Parameters = parameters.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("AlternativeActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         AlternativeActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("BeforeActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         BeforeActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("AfterActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         AfterActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }