Ejemplo n.º 1
0
        void ITwentyThreeParsable.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();
        }
Ejemplo n.º 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;

                case "takenunknown":
                    DateTakenUnknown = reader.Value == "1";
                    break;

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

            reader.Read();
        }
Ejemplo n.º 3
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "nsid":
                    InstitutionId = reader.Value;
                    break;

                case "date_launch":
                    DateLaunched = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

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

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "name":
                    InstitutionName = reader.ReadElementContentAsString();
                    break;

                case "urls":
                    reader.Read();
                    while (reader.LocalName == "url")
                    {
                        string type = reader.GetAttribute("type");
                        string url  = reader.ReadElementContentAsString();
                        switch (type)
                        {
                        case "site":
                            SiteUrl = url;
                            break;

                        case "flickr":
                            FlickrUrl = url;
                            break;

                        case "license":
                            LicenseUrl = url;
                            break;
                        }
                    }
                    reader.Read();
                    break;
                }
            }

            reader.Read();
        }
Ejemplo n.º 4
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photos")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "total":
                    Total = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "interval":
                    Interval = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "panda":
                    PandaName = reader.Value;
                    break;

                case "lastupdate":
                    LastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

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

            reader.Read();

            while (reader.LocalName == "photo")
            {
                var p = new Photo();
                ((ITwentyThreeParsable)p).Load(reader);
                if (!string.IsNullOrEmpty(p.PhotoId))
                {
                    Add(p);
                }
            }

            // Skip to next element (if any)
            reader.Skip();
        }
Ejemplo n.º 5
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "subscription")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

                case "callback":
                    Callback = reader.Value;
                    break;

                case "pending":
                    IsPending = reader.Value == "1";
                    break;

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

                case "lease_seconds":
                    LeaseSeconds = reader.ReadContentAsInt();
                    break;

                case "expiry":
                    Expiry = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "verify_attempts":
                    VerifyAttempts = reader.ReadContentAsInt();
                    break;

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

            reader.Read();
        }
Ejemplo n.º 6
0
        void ITwentyThreeParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "nsid":
                    UserId = reader.Value;
                    break;

                case "username":
                    UserName = reader.Value;
                    break;

                case "favedate":
                    FavoriteDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;
                }
            }

            reader.Skip();
        }
Ejemplo n.º 7
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;

                case "first_added":
                    DateFirstAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "last_added":
                    DateLastUsed = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;
                }
            }

            reader.Read();

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

            reader.Read();
        }
        void ITwentyThreeParsable.Load(System.Xml.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 "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 "author_iconfarm":
                    AuthorIconFarm = reader.Value;
                    break;

                case "author_iconserver":
                    AuthorIconServer = reader.Value;
                    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 "total":
                    Total = reader.ReadContentAsInt();
                    break;

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

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

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

                case "group_alias":
                    GroupAlias = reader.Value == "" ? null : reader.Value;
                    break;

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

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

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

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

            reader.Read();

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

            while (reader.LocalName == "reply" && reader.NodeType == System.Xml.XmlNodeType.Element)
            {
                var reply = new TopicReply();
                ((ITwentyThreeParsable)reply).Load(reader);
                Add(reply);
            }
        }
Ejemplo n.º 9
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "created":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "alpha":
                    Alpha = reader.ReadContentAsDouble();
                    break;

                case "count_points":
                    PointCount = reader.ReadContentAsInt();
                    break;

                case "count_edges":
                    EdgeCount = reader.ReadContentAsInt();
                    break;

                case "has_donuthole":
                    HasDonutHole = reader.Value == "1";
                    break;

                case "is_donuthole":
                    IsDonutHole = reader.Value == "1";
                    break;

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

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "polylines":
                    reader.Read();
                    while (reader.LocalName == "polyline")
                    {
                        var      polyline   = new Collection <PointD>();
                        string   polystring = reader.ReadElementContentAsString();
                        string[] points     = polystring.Split(' ');
                        foreach (string point in points)
                        {
                            string[] xy = point.Split(',');
                            if (xy.Length != 2)
                            {
                                throw new ParsingException("Invalid polypoint found in polyline : '" + polystring +
                                                           "'");
                            }
                            polyline.Add(
                                new PointD(
                                    double.Parse(xy[0], System.Globalization.NumberFormatInfo.InvariantInfo),
                                    double.Parse(xy[1], System.Globalization.NumberFormatInfo.InvariantInfo)));
                        }
                        PolyLines.Add(polyline);
                    }
                    reader.Read();
                    break;

                case "urls":
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }
Ejemplo n.º 10
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "values")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

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

                case "per_page":
                case "perpage":
                    PerPage = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

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

                case "added_since":
                    DateAddedSince = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "value":
                    // This sometimes gets returned - it always appears to be blank.
                    break;

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

            reader.Read();

            while (reader.LocalName == "value")
            {
                var item = new Value();
                ((ITwentyThreeParsable)item).Load(reader);
                if (!string.IsNullOrEmpty(NamespaceName) && string.IsNullOrEmpty(item.NamespaceName))
                {
                    item.NamespaceName = NamespaceName;
                }
                if (!string.IsNullOrEmpty(PredicateName) && string.IsNullOrEmpty(item.PredicateName))
                {
                    item.PredicateName = PredicateName;
                }
                Add(item);
            }

            reader.Skip();
        }
Ejemplo n.º 11
0
        void ITwentyThreeParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "type":
                    switch (reader.Value)
                    {
                    case "fave":
                        EventType = ActivityEventType.Favorite;
                        break;

                    case "note":
                        EventType = ActivityEventType.Note;
                        break;

                    case "comment":
                        EventType = ActivityEventType.Comment;
                        break;

                    case "added_to_gallery":
                        EventType = ActivityEventType.Gallery;
                        break;

                    case "tag":
                        EventType = ActivityEventType.Tag;
                        break;

                    case "group_invite":
                        EventType = ActivityEventType.GroupInvite;
                        break;

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

                case "user":
                    UserId = reader.Value;
                    break;

                case "username":
                    UserName = reader.Value;
                    break;

                case "dateadded":
                    DateAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "commentid":
                    CommentId = reader.Value;
                    break;

                case "noteid":
                    NoteId = reader.Value;
                    break;

                case "galleryid":
                    GalleryId = reader.Value;
                    break;

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

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

                case "realname":
                    RealName = reader.Value;
                    break;

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

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

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

            reader.Read();

            if (reader.NodeType == XmlNodeType.Text)
            {
                Value = reader.ReadContentAsString();
                reader.Read();
            }
        }
Ejemplo n.º 12
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "collection")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

                case "child_count":
                    ChildCount = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

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

                case "iconlarge":
                    IconLarge = reader.Value;
                    break;

                case "iconsmall":
                    IconSmall = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

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

            reader.Read();

            while (reader.LocalName != "collection")
            {
                switch (reader.Name)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "iconphotos":
                    reader.Read();

                    while (reader.LocalName == "photo")
                    {
                        var p = new Photo();
                        ((ITwentyThreeParsable)p).Load(reader);

                        _iconPhotos.Add(p);
                    }
                    reader.Read();
                    return;

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

            reader.Skip();
        }
Ejemplo n.º 13
0
        void ITwentyThreeParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "nsid":
                case "id":
                    GroupId = reader.Value;
                    break;

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

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

                case "lang":
                    Language = reader.Value;
                    break;

                case "ispoolmoderated":
                    IsPoolModerated = reader.Value == "1";
                    break;

                case "path_alias":
                    PathAlias = reader.Value == "" ? null : reader.Value;
                    break;

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

            reader.Read();

            while (reader.LocalName != "group")
            {
                switch (reader.LocalName)
                {
                case "name":
                    GroupName = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "members":
                    Members = reader.ReadElementContentAsInt();
                    break;

                case "privacy":
                    Privacy = (PoolPrivacy)reader.ReadElementContentAsInt();
                    break;

                case "blast":
                    BlastDateAdded = UtilityMethods.UnixTimestampToDate(reader.GetAttribute("date_blast_added"));
                    BlastUserId    = reader.GetAttribute("user_id");
                    BlastHtml      = reader.ReadElementContentAsString();
                    break;

                case "throttle":
                    ThrottleInfo = new GroupThrottleInfo();
                    ((ITwentyThreeParsable)ThrottleInfo).Load(reader);
                    break;

                case "restrictions":
                    Restrictions = new GroupInfoRestrictions();
                    ((ITwentyThreeParsable)Restrictions).Load(reader);
                    break;

                case "roles":
                    MemberRoleName    = reader.GetAttribute("member");
                    ModeratorRoleName = reader.GetAttribute("moderator");
                    AdminRoleName     = reader.GetAttribute("admin");
                    reader.Read();
                    break;

                case "rules":
                    Rules = reader.ReadElementContentAsString();
                    break;

                case "pool_count":
                    PoolCount = reader.ReadElementContentAsInt();
                    break;

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

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

            reader.Read();
        }
Ejemplo n.º 14
0
        private void LoadAttributes(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    PhotoId = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "farm":
                    Farm = reader.Value;
                    break;

                case "dateuploaded":
                    DateUploaded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "isfavorite":
                    IsFavorite = reader.Value == "1";
                    break;

                case "license":
                    License = (LicenseType)int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

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

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

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

                case "media":
                    Media = reader.Value == "photo" ? MediaType.Photos : MediaType.Videos;
                    break;

                case "safety_level":
                    SafetyLevel = (SafetyLevel)reader.ReadContentAsInt();
                    break;

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

            reader.Read();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Protected method that does the actual initialization of the Photo instance. Should be called by subclasses of the Photo class.
        /// </summary>
        /// <param name="reader">The reader containing the XML to be parsed.</param>
        /// <param name="allowExtraAtrributes">Wheither to allow unknown extra attributes.
        /// In debug builds will throw an exception if this parameter is false and an unknown attribute is found.</param>
        protected void Load(XmlReader reader, bool allowExtraAtrributes)
        {
            if (reader.LocalName != "photo" && reader.LocalName != "primary_photo_extras")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "photo":
                case "id":
                    PhotoId = reader.Value;
                    if (string.IsNullOrEmpty(reader.Value))
                    {
                        reader.Skip();
                        return;
                    }
                    break;

                case "owner":
                    UserId = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "farm":
                    Farm = reader.Value;
                    break;

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

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

                case "isfamily":
                    IsFamily = reader.Value == "1";
                    break;

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

                case "tags":
                    foreach (string tag in reader.Value.Split(' '))
                    {
                        Tags.Add(tag);
                    }
                    break;

                case "datetaken":
                    // For example : 2007-11-04 08:55:18
                    DateTaken = UtilityMethods.ParseDateWithGranularity(reader.Value);
                    break;

                case "datetakengranularity":
                    break;

                case "datetakenunknown":
                    DateTakenUnknown = reader.Value == "1";
                    break;

                case "dateupload":
                    DateUploaded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "license":
                    License = (LicenseType)int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "ownername":
                    OwnerName = reader.Value;
                    break;

                case "last_update":
                    LastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;
                    break;

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

                case "media":
                    Media = reader.Value;
                    break;

                case "media_status":
                    MediaStatus = reader.Value;
                    break;

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

                case "username":
                    OwnerName = reader.Value;
                    break;

                case "isprimary":
                case "is_primary":
                    break;

                case "dateadded":
                    DateAddedToGroup = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_faved":
                    DateFavorited = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "has_comment":     // Gallery photos return this, but we ignore it and set GalleryPhoto.Comment instead.
                    break;

                case "can_comment":
                    CanComment = reader.Value == "1";
                    break;

                case "can_addmeta":
                    CanAddMeta = reader.Value == "1";
                    break;

                case "can_blog":
                    CanBlog = reader.Value == "1";
                    break;

                case "can_print":
                    CanPrint = reader.Value == "1";
                    break;

                case "can_download":
                    CanDownload = reader.Value == "1";
                    break;

                case "can_share":
                    CanShare = reader.Value == "1";
                    break;

                case "geo_is_family":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsFamily = reader.Value == "1";
                    break;

                case "geo_is_friend":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsFriend = reader.Value == "1";
                    break;

                case "geo_is_public":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsPublic = reader.Value == "1";
                    break;

                case "geo_is_contact":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsContact = reader.Value == "1";
                    break;

                case "rotation":
                    Rotation = reader.ReadContentAsInt();
                    break;

                default:
                    if (!allowExtraAtrributes)
                    {
                        UtilityMethods.CheckParsingException(reader);
                    }
                    break;
                }
            }

            reader.Read();

            if (reader.LocalName == "description")
            {
                Description = reader.ReadElementContentAsString();
            }
        }
Ejemplo n.º 16
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    GalleryId = reader.Value;
                    break;

                case "url":
                    GalleryUrl = "https://www.23hq.com" + reader.Value;
                    break;

                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                    Username = reader.Value;
                    break;

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

                case "date_update":
                    DateLastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "primary_photo_id":
                    PrimaryPhotoId = reader.Value;
                    break;

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

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

                case "primary_photo_server":
                case "server":
                    PrimaryPhotoServer = reader.Value;
                    break;

                case "primary_photo_farm":
                case "farm":
                    PrimaryPhotoFarm = reader.Value;
                    break;

                case "primary_photo_secret":
                case "secret":
                    PrimaryPhotoSecret = reader.Value;
                    break;

                case "count_photos":
                    PhotosCount = reader.ReadContentAsInt();
                    break;

                case "count_videos":
                    VideosCount = reader.ReadContentAsInt();
                    break;

                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

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

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

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

            reader.Read();
        }
Ejemplo n.º 17
0
        void ITwentyThreeParsable.Load(System.Xml.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 "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;

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

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

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

            reader.Read();

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

            reader.Skip();
        }
Ejemplo n.º 18
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "comment")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

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

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

                case "permalink":
                    Permalink = reader.Value;
                    break;

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

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

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

                case "path_alias":
                    AuthorPathAlias = reader.Value;
                    break;

                case "realname":
                    AuthorRealName = reader.Value;
                    break;

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

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

            reader.Read();

            CommentHtml = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 19
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photoset")
            {
                UtilityMethods.CheckParsingException(reader);
            }

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

                case "url":
                    Url = reader.Value;
                    break;

                case "owner_id":
                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                case "ownername":
                    OwnerName = reader.Value;
                    break;

                case "primary":
                    PrimaryPhotoId = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                case "farm":
                    Farm = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "total":
                    break;

                case "photos":
                case "count_photos":
                    NumberOfPhotos = reader.ReadContentAsInt();
                    break;

                case "videos":
                case "count_videos":
                    NumberOfVideos = reader.ReadContentAsInt();
                    break;

                case "needs_interstitial":
                    // Who knows what this is for.
                    break;

                case "visibility_can_see_set":
                    // Who knows what this is for.
                    break;

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

                case "date_update":
                    DateUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "view_count":
                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "comment_count":
                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

                case "can_comment":
                    CanComment = reader.Value == "1";
                    break;

                case "coverphoto_server":
                case "coverphoto_farm":
                    break;

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

            reader.Read();

            PrimaryPhoto = new Photo
            {
                PhotoId   = PrimaryPhotoId,
                Secret    = Secret,
                Server    = Server,
                Farm      = Farm,
                OwnerName = OwnerName
            };

            while (reader.LocalName != "photoset" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "primary_photo_extras":
                    ((ITwentyThreeParsable)PrimaryPhoto).Load(reader);
                    break;

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

            reader.Read();
        }
Ejemplo n.º 20
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName != "suggestion")
            {
                UtilityMethods.CheckParsingException(reader); return;
            }

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

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

                case "date_suggested":
                    DateSuggested = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

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

            reader.Read();

            while (reader.LocalName != "suggestion" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "suggested_by":
                    SuggestedByUserId   = reader.GetAttribute("nsid");
                    SuggestedByUserName = reader.GetAttribute("username");
                    reader.Skip();
                    break;

                case "note":
                    Note = reader.ReadElementContentAsString();
                    break;

                case "location":
                    while (reader.MoveToNextAttribute())
                    {
                        switch (reader.LocalName)
                        {
                        case "woeid":
                            WoeId = reader.Value;
                            break;

                        case "latitude":
                            Latitude = reader.ReadContentAsDouble();
                            break;

                        case "longitude":
                            Longitude = reader.ReadContentAsDouble();
                            break;

                        case "accuracy":
                            Accuracy = (GeoAccuracy)reader.ReadContentAsInt();
                            break;

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

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }
        }
Ejemplo n.º 21
0
        void ITwentyThreeParsable.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();
        }