void IFlickrParsable.Load(XmlReader reader) { if (reader.LocalName != "photos") Helper.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: Helper.CheckParsingException(reader); break; } } reader.Read(); while (reader.LocalName == "photo") { Photo p = new Photo(); ((IFlickrParsable)p).Load(reader); if (!String.IsNullOrEmpty(p.PhotoId)) Add(p); } // Skip to next element (if any) reader.Skip(); }
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); }
void IFlickrParsable.Load(System.Xml.XmlReader reader) { if (reader.LocalName != "photoset") Helper.CheckParsingException(reader); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "id": PhotosetId = reader.Value; break; case "primary": PrimaryPhotoId = reader.Value; break; case "owner": OwnerId = reader.Value; break; case "ownername": OwnerName = reader.Value; break; 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 "perpage": case "per_page": PerPage = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo); break; case "title": Title = reader.Value; break; default: Helper.CheckParsingException(reader); break; } } reader.Read(); while (reader.LocalName == "photo") { Photo photo = new Photo(); ((IFlickrParsable)photo).Load(reader); if (String.IsNullOrEmpty(photo.UserId)) photo.UserId = OwnerId; Add(photo); } reader.Skip(); }