void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName != "reply")
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

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

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "author_path_alias":
                    AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                    break;

                case "author_is_deleted":
                    AuthorIsDeleted = reader.Value == "1";
                    break;

                case "is_pro":
                    AuthorIsPro = reader.Value == "1";
                    break;

                case "role":
                    AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                    break;

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

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

                case "can_edit":
                    CanEdit = reader.Value == "1";
                    break;

                case "can_delete":
                    CanDelete = reader.Value == "1";
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "lastedit":
                    DateLastEdited = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

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

            reader.Read();

            if (reader.LocalName == "message")
            {
                Message = reader.ReadElementContentAsString();
            }

            reader.Skip();
        }
예제 #2
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName != "topic")
            {
                UtilityMethods.CheckParsingException(reader); return;
            }

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

                case "subject":
                    Subject = reader.Value;
                    break;

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "is_pro":
                    AuthorIsPro = reader.Value == "1";
                    break;

                case "role":
                    AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                    break;

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

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

                case "count_replies":
                    RepliesCount = reader.ReadContentAsInt();
                    break;

                case "can_edit":
                    CanEdit = reader.Value == "1";
                    break;

                case "can_delete":
                    CanDelete = reader.Value == "1";
                    break;

                case "can_reply":
                    CanReply = reader.Value == "1";
                    break;

                case "is_sticky":
                    IsSticky = reader.Value == "1";
                    break;

                case "is_locked":
                    IsLocked = reader.Value == "1";
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "datelastpost":
                    DateLastPost = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "last_reply":
                    LastReplyId = reader.Value;
                    break;

                case "group_id":
                    GroupId = reader.Value;
                    break;

                case "name":
                    // Group Name
                    break;

                case "author_path_alias":
                    AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                    break;

                case "author_is_deleted":
                    AuthorIsDeleted = reader.Value == "1";
                    break;

                case "lastedit":
                    DateLastEdited = reader.Value == "" || reader.Value == "0" ? (DateTime?)null : UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "pro_badge":
                    ProBadgeStyle = reader.Value;
                    break;

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

            reader.Read();

            if (reader.LocalName == "message")
            {
                Message = reader.ReadElementContentAsString();
            }

            reader.Skip();
        }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName != "replies")
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

            reader.Read();
            if (reader.LocalName != "topic")
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

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

                case "subject":
                    Subject = reader.Value;
                    break;

                case "group_id":
                    GroupId = reader.Value;
                    break;

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

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "author_path_alias":
                    AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                    break;

                case "is_pro":
                    AuthorIsPro = reader.Value == "1";
                    break;

                case "role":
                    AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                    break;

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

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

                case "group_alias":
                    GroupAlias = reader.Value;
                    if (GroupAlias == String.Empty)
                    {
                        GroupAlias = null;
                    }
                    break;

                case "author_iconfarm":
                    AuthorIconFarm = reader.Value;
                    break;

                case "author_iconserver":
                    AuthorIconServer = reader.Value;
                    break;

                case "author_is_deleted":
                    AuthorIsDeleted = reader.Value == "1";
                    break;

                case "can_edit":
                    CanEdit = reader.Value == "1";
                    break;

                case "can_delete":
                    CanDelete = reader.Value == "1";
                    break;

                case "can_reply":
                    CanReply = reader.Value == "1";
                    break;

                case "is_sticky":
                    IsSticky = reader.Value == "1";
                    break;

                case "is_locked":
                    IsLocked = reader.Value == "1";
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "datelastpost":
                    DateLastPost = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "lastedit":
                    DateLastEdit = reader.Value == "0" ? null : (DateTime?)UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

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

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

                case "page":
                    Page = reader.ReadContentAsInt();
                    break;

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

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

            reader.Read();

            if (reader.LocalName == "message")
            {
                Message = reader.ReadElementContentAsString();
                reader.Read();
            }

            while (reader.LocalName == "reply" && reader.NodeType == XmlNodeType.Element)
            {
                var reply = new TopicReply();
                ((IFlickrParsable)reply).Load(reader);
                Add(reply);
            }
        }