internal static string SortOrderToString(PhotoSearchSortOrder order) { switch (order) { case PhotoSearchSortOrder.DatePostedAsc: return("date-posted-asc"); case PhotoSearchSortOrder.DatePostedDesc: return("date-posted-desc"); case PhotoSearchSortOrder.DateTakenAsc: return("date-taken-asc"); case PhotoSearchSortOrder.DateTakenDesc: return("date-taken-desc"); case PhotoSearchSortOrder.InterestingnessAsc: return("interestingness-asc"); case PhotoSearchSortOrder.InterestingnessDesc: return("interestingness-desc"); case PhotoSearchSortOrder.Relevance: return("relevance"); default: return(null); } }
/// <summary> /// Converts a <see cref="PhotoSearchSortOrder"/> into a string for use by the Flickr API. /// </summary> /// <param name="order">The sort order to convert.</param> /// <returns>The string representative for the sort order.</returns> public static string SortOrderToString(PhotoSearchSortOrder order) { switch (order) { case PhotoSearchSortOrder.DatePostedAscending: return "date-posted-asc"; case PhotoSearchSortOrder.DatePostedDescending: return "date-posted-desc"; case PhotoSearchSortOrder.DateTakenAscending: return "date-taken-asc"; case PhotoSearchSortOrder.DateTakenDescending: return "date-taken-desc"; case PhotoSearchSortOrder.InterestingnessAscending: return "interestingness-asc"; case PhotoSearchSortOrder.InterestingnessDescending: return "interestingness-desc"; case PhotoSearchSortOrder.Relevance: return "relevance"; default: return String.Empty; } }
public Task <FlickrResult <PhotoCollection> > SearchPhotos(string searchText, PhotoSearchSortOrder sortOrder) { PhotoSearchOptions photoSearchOptions = new PhotoSearchOptions() { Extras = PhotoSearchExtras.All, SortOrder = sortOrder, Tags = searchText }; var flickr = _flickrService.GetInstance(); var taskCompletionSource = new TaskCompletionSource <FlickrResult <PhotoCollection> >(); flickr.PhotosSearchAsync(photoSearchOptions, result => { taskCompletionSource.SetResult(result); }); return(taskCompletionSource.Task); }