SortOrderToString() public static method

Converts a PhotoSearchSortOrder into a string for use by the Flickr API.
public static SortOrderToString ( PhotoSearchSortOrder order ) : string
order PhotoSearchSortOrder The sort order to convert.
return string
Ejemplo n.º 1
0
        /// <summary>
        /// List the photos with the most views, comments or favorites.
        /// </summary>
        /// <param name="date">Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will automatically be rounded down to the start of the day. If no date is provided, all time view counts will be returned.</param>
        /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
        /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
        /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
        public PopularPhotoCollection StatsGetPopularPhotos(DateTime date, PopularitySort sort, int page, int perPage)
        {
            CheckRequiresAuthentication();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.stats.getPopularPhotos");
            if (date != DateTime.MinValue)
            {
                parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            }
            if (sort != PopularitySort.None)
            {
                parameters.Add("sort", UtilityMethods.SortOrderToString(sort));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            return(GetResponseCache <PopularPhotoCollection>(parameters));
        }