Пример #1
0
        Type DeserializeType(System.Xml.XmlReader reader)
        {
            Type   result    = null;
            bool   isGeneric = bool.Parse(reader.GetAttribute("generic"));
            string name      = reader.GetAttribute("name");

            result = TypeExtensions.GetTypeEx(name);

            if (isGeneric)
            {
                int    args  = int.Parse(reader.GetAttribute("count"));
                Type[] types = new Type[args];
                reader.ReadStartElement("type");
                while (reader.MoveToNextAttribute())
                {
                    ;
                }
                for (int i = 0; i < args; ++i)
                {
                    types[i] = DeserializeType(reader);
                }
                result = result.MakeGenericType(types);
                reader.ReadEndElement();
            }
            else
            {
                reader.ReadStartElement("type");
                while (reader.MoveToNextAttribute())
                {
                    ;
                }
            }
            return(result);
        }
Пример #2
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();
        }
Пример #3
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case XmlAttribute_ColumnName:
                    this.ColumnName = reader.Value;
                    break;

                case XmlAttribute_Seed:
                    this.Seed = Convert.ToInt64(reader.Value);
                    break;

                case XmlAttribute_Increment:
                    this.Increment = Convert.ToInt64(reader.Value);
                    break;
                }
            }

            reader.MoveToContent();

            // Elements
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Пример #4
0
        private void ParseOwner(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "nsid":
                        OwnerUserId = reader.Value;
                        break;
                    case "username":
                        OwnerUserName = reader.Value;
                        break;
                    case "realname":
                        OwnerRealName = reader.Value;
                        break;
                    case "location":
                        OwnerLocation = reader.Value;
                        break;
                    case "iconserver":
                        OwnerIconServer = reader.Value;
                        break;
                    case "iconfarm":
                        OwnerIconFarm = reader.Value;
                        break;
                    case "path_alias":
                        PathAlias = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
Пример #5
0
        private void ParseUsage(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "canblog":
                        CanBlog = reader.Value == "1";
                        break;
                    case "candownload":
                        CanDownload = reader.Value == "1";
                        break;
                    case "canprint":
                        CanPrint = reader.Value == "1";
                        break;
                    case "canshare":
                        CanShare = reader.Value == "1";
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
Пример #6
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photocount")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "count":
                    Count = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "fromdate":
                    FromDate = System.Text.RegularExpressions.Regex.IsMatch(reader.Value, "^\\d+$") ? UtilityMethods.UnixTimestampToDate(reader.Value) : UtilityMethods.MySqlToDate(reader.Value);
                    break;

                case "todate":
                    ToDate = System.Text.RegularExpressions.Regex.IsMatch(reader.Value, "^\\d+$") ? UtilityMethods.UnixTimestampToDate(reader.Value) : UtilityMethods.MySqlToDate(reader.Value);
                    break;

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

            reader.Read();
        }
Пример #7
0
        private void ParseVisibility(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "isfamily":
                    IsFamily = reader.Value == "1";
                    break;

                case "ispublic":
                    IsPublic = reader.Value == "1";
                    break;

                case "isfriend":
                    IsFriend = reader.Value == "1";
                    break;

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

            reader.Read();
        }
Пример #8
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "source":
                    SourceTag = reader.Value;
                    break;

                case "total":
                    TotalClusters = reader.ReadContentAsInt();
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName == "cluster")
            {
                var item = new Cluster();
                ((IFlickrParsable)item).Load(reader);
                item.SourceTag = SourceTag;
                Add(item);
            }

            reader.Skip();
        }
Пример #9
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    TicketId = reader.Value;
                    break;

                case "invalid":
                    InvalidTicketId = true;
                    break;

                case "photoid":
                    PhotoId = reader.Value;
                    break;

                case "complete":
                    CompleteStatus = reader.ReadContentAsInt();
                    break;
                }
            }

            reader.Skip();
        }
Пример #10
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "comments")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "photoset_id":
                    PhotosetId = reader.Value;
                    break;

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

            reader.Read();

            while (reader.LocalName == "comment")
            {
                var comment = new PhotoComment();
                ((IFlickrParsable)comment).Load(reader);
                Add(comment);
            }
            reader.Skip();
        }
Пример #11
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "stats")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "views":
                    Views = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "comments":
                    Comments = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "favorites":
                    Favorites = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Skip();
        }
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "shapes")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

                case "total":
                    Total = reader.ReadContentAsInt();
                    break;

                case "pages":
                    Pages = reader.ReadContentAsInt();
                    break;

                case "per_page":
                case "perpage":
                    PerPage = reader.ReadContentAsInt();
                    break;

                case "woe_id":
                    WoeId = reader.Value;
                    break;

                case "place_id":
                    PlaceId = reader.Value;
                    break;

                case "place_type_id":
                    PlaceType = (PlaceType)reader.ReadContentAsInt();
                    break;

                case "place_type":
                    break;

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

            reader.Read();

            while (reader.LocalName == "shape")
            {
                var item = new ShapeData();
                ((ITwentyThreeParsable)item).Load(reader);
                Add(item);
            }

            reader.Skip();
        }
Пример #13
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case XmlAttribute_Column:
                    this.Column = reader.Value;
                    break;

                case XmlAttribute_Sort:
                    this.Sort = (SortOrder)Enum.Parse(typeof(SortOrder), reader.Value);
                    break;
                }
            }

            reader.MoveToContent();

            // Elements
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
 /// <summary>Initializes a new instance of RssCloud</summary>
 public RssCloud(System.Xml.XmlReader xmlTextReader)
 {
     if (!xmlTextReader.HasAttributes)
     {
         return;
     }
     //
     System.Reflection.PropertyInfo propertyInfo = null;
     //
     while (xmlTextReader.MoveToNextAttribute())
     {
         // find related property by name
         propertyInfo = GetType().GetProperty(xmlTextReader.Name, System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
         if (propertyInfo != null)
         {
             // Protocol enum needs some conversion before the typeconverter can set the values that contains - char
             if (propertyInfo.Name == "Protocol")
             {
                 propertyInfo.SetValue(this, System.ComponentModel.TypeDescriptor.GetConverter(propertyInfo.PropertyType).ConvertFromString(xmlTextReader.ReadInnerXml().Trim().Replace("-", "")), null);
             }
             else
             {
                 XmlSerializationUtil.DecodeXmlTextReaderValue(this, xmlTextReader);
             }
         }
     }
 }
Пример #15
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Attributes
            while (reader.MoveToNextAttribute())
            {
            }

            reader.MoveToContent();

            // Elements
            if (!reader.IsEmptyElement)
            {
                // Read first element
                reader.ReadStartElement();
                while (reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case TableModel.XmlElement_Tag:
                        TableModel table = new TableModel();
                        table.ReadXml(reader);
                        this.Add(table);
                        break;

                    default:
                        throw new InvalidOperationException(reader.Name);
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Пример #16
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "period":
                    Period = reader.Value;
                    break;

                case "count":
                    TagCount = reader.ReadContentAsInt();
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName == "tag")
            {
                var item = new HotTag();
                ((ITwentyThreeParsable)item).Load(reader);
                Add(item);
            }

            reader.Skip();
        }
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "url")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "type":
                    UrlType = reader.Value;
                    break;

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

            reader.Read();

            Url = reader.ReadContentAsString();

            reader.Skip();
        }
Пример #18
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    LicenseId = (LicenseType)reader.ReadContentAsInt();
                    break;

                case "name":
                    LicenseName = reader.Value;
                    break;

                case "url":
                    if (!string.IsNullOrEmpty(reader.Value))
                    {
                        LicenseUrl = reader.Value;
                    }
                    break;

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

            reader.Read();
        }
Пример #19
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "referrer")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "url":
                    Url = reader.Value;
                    break;

                case "searchterm":
                    SearchTerm = reader.Value;
                    break;

                case "views":
                    Views = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Skip();
        }
Пример #20
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            // Attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case XmlAttribute_Name:
                    this.Name = reader.Value;
                    break;

                case XmlAttribute_Columns:
                    this.Columns = reader.Value.Split(new string[] { DatabaseHelper.Separator }, StringSplitOptions.RemoveEmptyEntries);
                    break;
                }
            }

            reader.MoveToContent();

            // Element
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Пример #21
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "url")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "type":
                    UrlType = reader.Value;
                    break;

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

            reader.Read();

            Url = reader.ReadContentAsString();

            if (Url.Contains("www.flickr.com"))
            {
                Url = Url.Replace("http://", "https://");
            }

            reader.Skip();
        }
Пример #22
0
        private static ErrorStatus ReadCode(System.Xml.XmlReader reader)
        {
            ErrorStatus status = new ErrorStatus();

            reader.MoveToContent();
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "name":
                    reader.ReadAttributeValue();
                    status.Name = reader.ReadContentAsString(); break;

                case "value":
                    reader.ReadAttributeValue();
                    var val = reader.ReadContentAsString();
                    status.Value = Convert.ToInt32(val, 16); break;

                case "comment":
                    reader.ReadAttributeValue();
                    status.Comment = reader.ReadContentAsString(); break;

                default:
                    reader.ReadAttributeValue(); break;
                }
            }
            return(status);
        }
Пример #23
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Attributes
            while (reader.MoveToNextAttribute())
            {
            }

            reader.MoveToContent();

            // Element
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case ColumnModel.XmlElement_Tag:
                        ColumnModel column = new ColumnModel();
                        column.ReadXml(reader);
                        this.Add(column);
                        break;

                    default:
                        throw new InvalidOperationException(reader.Name);
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Пример #24
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "place_type")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "place_type_id":
                case "id":
                    Id = reader.ReadContentAsInt();
                    break;

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

            reader.Read();

            Name = reader.ReadContentAsString();

            reader.Skip();
        }
Пример #25
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "usage":
                    Usage = reader.ReadContentAsInt();
                    break;

                case "predicate":
                    PredicateName = reader.Value;
                    break;

                case "namespace":
                    NamespaceName = reader.Value;
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                PairName = reader.ReadContentAsString();
            }

            reader.Read();
        }
Пример #26
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "category")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    SubcategoryId = reader.Value;
                    break;

                case "name":
                    SubcategoryName = reader.Value;
                    break;

                case "count":
                    GroupCount = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Read();
        }
Пример #27
0
        private void ParseDates(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "posted":
                        DatePosted = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "taken":
                        DateTaken = UtilityMethods.ParseDateWithGranularity(reader.Value);
                        break;
                    case "takengranularity":
                        DateTakenGranularity = (DateGranularity)int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "lastupdate":
                        DateLastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "nsid":
                case "id":
                    GroupId = reader.Value;
                    break;

                case "name":
                    GroupName = reader.Value;
                    break;

                case "admin":
                    IsAdmin = reader.Value == "1";
                    break;

                case "privacy":
                    Privacy = (PoolPrivacy)Enum.Parse(typeof(PoolPrivacy), reader.Value, true);
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                case "photos":
                case "pool_count":
                    Photos = long.Parse(reader.Value, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "member":
                    IsMember = reader.Value == "1";
                    break;

                case "moderator":
                    IsModerator = reader.Value == "1";
                    break;

                case "member_count":
                    MemberCount = reader.ReadContentAsInt();
                    break;

                case "topic_count":
                    TopicCount = reader.ReadContentAsInt();
                    break;

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

            reader.Read();
        }
Пример #29
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "usage":
                    Usage = reader.ReadContentAsInt();
                    break;

                case "predicates":
                    Predicates = reader.ReadContentAsInt();
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                NamespaceName = reader.ReadContentAsString();
            }

            reader.Read();
        }
Пример #30
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "domain")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "name":
                    Name = reader.Value;
                    break;

                case "views":
                    Views = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Skip();
        }