public async Task<Collection<Photo>> SearchAsync(PhotoSearchOption option) { if (_flickr == null) throw new Exception("Flickr service is not initialized"); var photos = await _flickr.PhotosSearchAsync(new PhotoSearchOptions { Text = option.SearchTerm, Page = option.PageNumber, PerPage = option.PageSize, HasGeo = true, Extras = PhotoSearchExtras.Geo }); var photoCol = new Collection<Photo>(); foreach (var photo in photos) { photoCol.Add(new Photo { SearchRequestId = option.SearchRequestId, Id = photo.PhotoId, Title = photo.Title, Description = photo.Description, ThumbnailUrl = photo.SquareThumbnailUrl, ImageUrl = SelectImageUrl(photo), Location = GetLocation(photo) }); } return photoCol; }
public FakeCollectionCollection() { fake_collection = new CollectionCollection(); // ------------- Highest level ----------- FlickrNet.Collection colA = new Collection(); colA.Title = "Collection A"; colA.CollectionId = "A"; FlickrNet.Collection colB = new Collection(); colB.Title = "Collection B"; colB.CollectionId = "B"; fake_collection.Add(colA); fake_collection.Add(colB); // ------------ Second level -------------- FlickrNet.Collection colAA = new Collection(); colAA.Title = "Collection A.A"; colAA.CollectionId = "A.A"; FlickrNet.Collection colAB = new Collection(); colAB.Title = "Collection A.B"; colAB.CollectionId = "A.B"; colA.Collections.Add(colAA); colA.Collections.Add(colAB); // ------------ Photo sets --------------- CollectionSet ps1 = new CollectionSet(); ps1.SetId = "ps1"; ps1.Title = "PhotoSet 1"; CollectionSet ps2 = new CollectionSet(); ps2.SetId = "ps2"; ps2.Title = "PhotoSet 2"; colAA.Sets.Add(ps1); colB.Sets.Add(ps2); }
void IFlickrParsable.Load(System.Xml.XmlReader reader) { Tags = new Collection<string>(); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "total": TotalTags = reader.ReadContentAsInt(); break; } } reader.Read(); while (reader.LocalName == "tag") { Tags.Add(reader.ReadElementContentAsString()); } reader.Read(); }
/// <summary> /// Default constructor for <see cref="FavoriteContext"/> /// </summary> public FavoriteContext() { PreviousPhotos = new Collection<FavoriteContextPhoto>(); NextPhotos = new Collection<FavoriteContextPhoto>(); }
void IFlickrParsable.Load(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 != 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], NumberFormatInfo.InvariantInfo), double.Parse(xy[1], NumberFormatInfo.InvariantInfo))); } PolyLines.Add(polyline); } reader.Read(); break; case "urls": reader.Skip(); break; } } reader.Read(); }
/// <summary> /// Default constructor. /// </summary> public ShapeData() { PolyLines = new Collection<Collection<PointD>>(); Urls = new Collection<string>(); }
/// <summary> /// Default constructor. /// </summary> public AllContexts() { Sets = new Collection<ContextSet>(); Groups = new Collection<ContextGroup>(); }
/// <summary> /// Default constructor. /// </summary> public GroupCategory() { Subcategories = new Collection<Subcategory>(); Groups = new Collection<Group>(); }
/// <summary> /// Initializes a new instance of the <see cref="Photo"/> class. /// </summary> public Photo() { Tags = new Collection<string>(); }
/// <summary> /// Creates a new instance of the search options. /// </summary> public PhotoSearchOptions() { ColorCodes = new Collection<string>(); }
void IFlickrParsable.Load(XmlReader reader) { if (!(reader.LocalName != "collection")) ; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "id": this.CollectionId = reader.Value; continue; case "title": this.Title = reader.Value; continue; case "description": this.Description = reader.Value; continue; case "iconlarge": this.IconLarge = reader.Value; continue; case "iconsmall": this.IconSmall = reader.Value; continue; case "url": this.Url = reader.Value; continue; default: continue; } } reader.MoveToElement(); if (reader.IsEmptyElement) { reader.Skip(); } else { reader.Read(); while (reader.NodeType == XmlNodeType.Element && (reader.LocalName == "collection" || reader.LocalName == "set")) { if (reader.LocalName == "collection") { Collection collection = new Collection(); collection.Load(reader); this.subcollections.Add(collection); } else { CollectionSet collectionSet = new CollectionSet(); collectionSet.Load(reader); this.subsets.Add(collectionSet); } } reader.Skip(); } }
void IFlickrParsable.Load(XmlReader reader) { if (reader.LocalName != "collection") UtilityMethods.CheckParsingException(reader); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "id": CollectionId = reader.Value; break; case "title": Title = reader.Value; break; case "description": Description = reader.Value; break; case "iconlarge": IconLarge = reader.Value; break; case "iconsmall": IconSmall = reader.Value; break; case "url": Url = reader.Value; break; default: UtilityMethods.CheckParsingException(reader); break; } } reader.MoveToElement(); // If this is an empty collection then skip to next item, which wont be a child, but may be a sibling. if (reader.IsEmptyElement) { reader.Skip(); return; } reader.Read(); while (reader.NodeType == XmlNodeType.Element && (reader.LocalName == "collection" || reader.LocalName == "set")) { if (reader.LocalName == "collection") { var c = new Collection(); ((IFlickrParsable)c).Load(reader); _subcollections.Add(c); } else { var s = new CollectionSet(); ((IFlickrParsable)s).Load(reader); _subsets.Add(s); } } // Skip to next element (if any) reader.Skip(); }
/// <summary> /// Default constructor. /// </summary> public PhotoInfo() { Notes = new Collection<PhotoInfoNote>(); Tags = new Collection<PhotoInfoTag>(); Urls = new Collection<PhotoInfoUrl>(); }
void IFlickrParsable.Load(XmlReader reader) { while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "created": this.DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value); continue; case "alpha": this.Alpha = reader.ReadContentAsDouble(); continue; case "count_points": this.PointCount = reader.ReadContentAsInt(); continue; case "count_edges": this.EdgeCount = reader.ReadContentAsInt(); continue; case "has_donuthole": this.HasDonutHole = reader.Value == "1"; continue; case "is_donuthole": this.IsDonutHole = reader.Value == "1"; continue; default: continue; } } reader.Read(); while (reader.NodeType != XmlNodeType.EndElement) { switch (reader.LocalName) { case "polylines": reader.Read(); while (reader.LocalName == "polyline") { Collection<PointD> collection = new Collection<PointD>(); string str1 = reader.ReadElementContentAsString(); string str2 = str1; char[] chArray1 = new char[1] { ' ' }; foreach (string str3 in str2.Split(chArray1)) { char[] chArray2 = new char[1] { ',' }; string[] strArray = str3.Split(chArray2); if (strArray.Length != 2) throw new ParsingException("Invalid polypoint found in polyline : '" + str1 + "'"); collection.Add(new PointD(double.Parse(strArray[0], (IFormatProvider) NumberFormatInfo.InvariantInfo), double.Parse(strArray[1], (IFormatProvider) NumberFormatInfo.InvariantInfo))); } this.PolyLines.Add(collection); } reader.Read(); continue; case "urls": reader.Skip(); continue; default: continue; } } reader.Read(); }
void IFlickrParsable.Load(XmlReader reader) { if (reader.LocalName != "collection") UtilityMethods.CheckParsingException(reader); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "id": CollectionId = reader.Value; break; case "title": Title = reader.Value; break; case "description": Description = reader.Value; break; case "iconlarge": IconLarge = reader.Value; break; case "iconsmall": IconSmall = reader.Value; break; case "url": Url = reader.Value; break; default: UtilityMethods.CheckParsingException(reader); break; } } reader.Read(); while (reader.NodeType == XmlNodeType.Element && (reader.LocalName == "collection" || reader.LocalName == "set")) { if (reader.LocalName == "collection") { Collection c = new Collection(); ((IFlickrParsable)c).Load(reader); subcollections.Add(c); } else { CollectionSet s = new CollectionSet(); ((IFlickrParsable)s).Load(reader); subsets.Add(s); } } // Skip to next element (if any) reader.Skip(); }