CheckParsingException() private method

private CheckParsingException ( XmlReader reader ) : void
reader XmlReader
return void
示例#1
0
        void IFlickrParsable.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();
        }
示例#2
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(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();
        }
示例#4
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();
        }
示例#5
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "error")
            {
                return;
            }

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

                case "message":
                    Message = reader.Value;
                    break;

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

            reader.Read();

            if (reader.NodeType == XmlNodeType.Text)
            {
                Description = reader.ReadContentAsString();
                reader.Read();
            }
        }
示例#6
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "comments")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

            reader.Read();

            while (reader.LocalName == "comment")
            {
                PhotoComment comment = new PhotoComment();
                ((IFlickrParsable)comment).Load(reader);
                Add(comment);
            }
            reader.Skip();
        }
示例#7
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();
        }
示例#8
0
        private void LoadElements(XmlReader reader)
        {
            while (reader.LocalName != "item")
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "activity":
                    reader.ReadToDescendant("event");
                    while (reader.LocalName == "event")
                    {
                        ActivityEvent e = new ActivityEvent();
                        ((IFlickrParsable)e).Load(reader);
                        Events.Add(e);
                    }
                    reader.Read();
                    break;

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

            reader.Read();
        }
示例#9
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "clean":
                    CleanTag = reader.ReadContentAsString();
                    break;

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

            reader.Read();

            while (reader.LocalName == "raw")
            {
                RawTags.Add(reader.ReadElementContentAsString());
            }

            reader.Read();
        }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "group")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

                case "eighteenplus":
                    EighteenPlus = reader.Value == "1";
                    break;

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

            reader.Skip();
        }
示例#11
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "brand")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

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

            reader.Skip();
        }
示例#12
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "count" && !reader.ReadToFollowing("count"))
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

            Count = reader.ReadElementContentAsInt();

            if (reader.LocalName != "prevphotos")
            {
                reader.ReadToFollowing("prevphotos");
            }
            reader.ReadToDescendant("photo");
            while (reader.LocalName == "photo")
            {
                FavoriteContextPhoto photo = new FavoriteContextPhoto();
                ((IFlickrParsable)photo).Load(reader);
                PreviousPhotos.Add(photo);
            }

            if (reader.LocalName != "nextphotos")
            {
                reader.ReadToFollowing("nextphotos");
            }
            reader.ReadToDescendant("photo");
            while (reader.LocalName == "photo")
            {
                FavoriteContextPhoto photo = new FavoriteContextPhoto();
                ((IFlickrParsable)photo).Load(reader);
                NextPhotos.Add(photo);
            }
        }
        void IFlickrParsable.Load(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, NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Read();
        }
        void IFlickrParsable.Load(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();
        }
示例#15
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();
        }
        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();
        }
示例#17
0
        void IFlickrParsable.Load(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();
                ((IFlickrParsable)item).Load(reader);
                Add(item);
            }

            reader.Skip();
        }
示例#18
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "nsid":
                    GroupId = reader.Value;
                    break;

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

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

                case "eighteenplus":
                    EighteenPlus = reader.Value == "1";
                    break;

                case "invitation_only":
                    InvitationOnly = reader.Value == "1";
                    break;

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

            reader.Read();
        }
示例#19
0
        void IFlickrParsable.Load(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, NumberFormatInfo.InvariantInfo);
                    break;

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

            reader.Skip();
        }
示例#20
0
        private void ParseSets(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "created":
                    if (!String.IsNullOrEmpty(reader.Value))
                    {
                        SetsCreated = reader.ReadContentAsInt();
                    }
                    break;

                case "remaining":
                    if (!String.IsNullOrEmpty(reader.Value) && reader.Value != "lots")
                    {
                        SetsRemaining = reader.ReadContentAsInt();
                    }
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }
            reader.Read();
        }
示例#21
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();
        }
示例#22
0
        private void ParseFileSize(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "maxbytes":
                case "max":
                    FileSizeMax = reader.ReadContentAsLong();
                    break;

                case "maxkb":
                    FileSizeMaxKB = reader.ReadContentAsLong();
                    break;

                case "maxmb":
                    FileSizeMaxMB = reader.ReadContentAsLong();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }
            reader.Read();
        }
示例#23
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "argument")
            {
                return;
            }

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

                case "optional":
                    IsOptional = reader.Value == "1";
                    break;

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

            reader.Read();

            Description = reader.ReadContentAsString();

            reader.Read();
        }
        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();
        }
示例#25
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();
        }
示例#26
0
文件: Auth.cs 项目: vittichy/Flup
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.LocalName != "auth" && reader.LocalName != "oauth")
            {
                switch (reader.LocalName)
                {
                case "token":
                    Token = reader.ReadElementContentAsString();
                    break;

                case "perms":
                    Permissions = (AuthLevel)Enum.Parse(typeof(AuthLevel), reader.ReadElementContentAsString(), true);
                    break;

                case "user":
                    User = new FoundUser();
                    ((IFlickrParsable)User).Load(reader);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }
        }
示例#27
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();
        }
示例#28
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "set")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

                case "title":
                    Title = reader.Value;
                    break;

                case "description":
                    Description = reader.Value;
                    break;

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

            reader.Skip();
        }
示例#29
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.LocalName != "photos")
            {
                switch (reader.LocalName)
                {
                case "firstdatetaken":
                    FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
                    break;

                case "firstdate":
                    FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
                    break;

                case "count":
                    PhotoCount = reader.ReadElementContentAsInt();
                    break;

                case "views":
                    Views = reader.ReadElementContentAsInt();
                    break;

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

            reader.Read();
        }
示例#30
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "comment")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

            reader.Read();


            reader.Skip();
        }