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 PhotoDownloaderTask() : base(nameof(PhotoDownloaderTask), 250 /* ms */) { _messengerService = Resolver.Instance.Resolve<IMessengerService>(); _flickrService = Resolver.Instance.Resolve<IFlickrService>(); _searchOption = new PhotoSearchOption { PageNumber = 1, PageSize = DefaultPageSize }; _isMorePageAvailable = new ManualResetEventSlim(false); // listen for these events _messengerService.Register<SearchPhotoEvent>(OnSearchPhoto); _messengerService.Register<SearchPhotoEndEvent>(OnSearchPhotoEnd); }