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

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "total":
                        Total = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "perpage":
                    case "per_page":
                        PerPage = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "page":
                        Page = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "pages":
                        Pages = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;

                }
            }

            reader.Read();

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

            // Skip to next element (if any)
            reader.Skip();
        }
Beispiel #2
0
        void IFlickrParsable.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":
                        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
            };

            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":
                        ((IFlickrParsable)PrimaryPhoto).Load(reader);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
 internal static string UrlFormat(Photo p, string size, string extension)
 {
     if (size == "_o" || size == "original")
         return UrlFormat(p.Farm, p.Server, p.PhotoId, p.OriginalSecret, size, extension);
     else
         return UrlFormat(p.Farm, p.Server, p.PhotoId, p.Secret, size, extension);
 }
Beispiel #4
0
        void IFlickrParsable.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":
                    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
            };

            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":
                    ((IFlickrParsable)PrimaryPhoto).Load(reader);
                    break;

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

            reader.Read();
        }