DateToUnixTimestamp() 공개 정적인 메소드

Converts a DateTime object into a unix timestamp number.
public static DateToUnixTimestamp ( System.DateTime date ) : string
date System.DateTime The date to convert.
리턴 string
예제 #1
0
        /// <summary>
        /// Get a list of referrers from a given domain to a photostream.
        /// </summary>
        /// <param name="date">The date to return stats for.</param>
        /// <param name="domain">The domain to return referrers for.
        /// This should be a hostname (eg: "flickr.com") with no protocol or pathname.</param>
        /// <param name="page">The page of the results to return. Default is 1.</param>
        /// <param name="perPage">The number of referrers to return per page. The default is 25 and the maximum is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void StatsGetPhotostreamReferrersAsync(DateTime date, string domain, int page, int perPage,
                                                      Action <FlickrResult <StatReferrerCollection> > callback)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.stats.getPhotostreamReferrers");
            parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            parameters.Add("domain", domain);
            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));
            }

            GetResponseAsync <StatReferrerCollection>(parameters, callback);
        }
예제 #2
0
        /// <summary>
        /// Gets the places of a particular type that the authenticated user has geotagged photos.
        /// </summary>
        /// <param name="placeType">The type of places to return.</param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters.</param>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param>
        /// <param name="threshold">The minimum number of photos that a place type must have to be included. If the number of photos is lowered then the parent place type for that place will be used.
        /// For example if you only have 3 photos taken in the locality of Montreal (WOE ID 3534) but your threshold is set to 5 then those photos will be "rolled up" and included instead with a place record for the region of Quebec (WOE ID 2344924).</param>
        /// <param name="minUploadDate">Minimum upload date. Photos with an upload date greater than or equal to this value will be returned.</param>
        /// <param name="maxUploadDate">Maximum upload date. Photos with an upload date less than or equal to this value will be returned. </param>
        /// <param name="minTakenDate">Minimum taken date. Photos with an taken date greater than or equal to this value will be returned. </param>
        /// <param name="maxTakenDate">Maximum taken date. Photos with an taken date less than or equal to this value will be returned. </param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public async Task <FlickrResult <PlaceCollection> > PlacesPlacesForUserAsync(PlaceType placeType, string woeId, string placeId, int threshold, DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.places.placesForUser");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (!String.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }
            if (!String.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            return(await GetResponseAsync <PlaceCollection>(parameters));
        }
예제 #3
0
        /// <summary>
        /// Return a list of the top 100 unique tags for a Flickr Places or Where on Earth (WOE) ID.
        /// </summary>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters.
        /// (While optional, you must pass either a valid Places ID or a WOE ID.)</param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters.
        /// (While optional, you must pass either a valid Places ID or a WOE ID.)</param>
        /// <param name="minUploadDate">Minimum upload date. Photos with an upload date greater than or equal to this value will be returned.</param>
        /// <param name="maxUploadDate">Maximum upload date. Photos with an upload date less than or equal to this value will be returned.</param>
        /// <param name="minTakenDate">Minimum taken date. Photos with an taken date greater than or equal to this value will be returned.</param>
        /// <param name="maxTakenDate">Maximum taken date. Photos with an taken date less than or equal to this value will be returned.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesTagsForPlaceAsync(string placeId, string woeId, DateTime minUploadDate, DateTime maxUploadDate,
                                            DateTime minTakenDate, DateTime maxTakenDate,
                                            Action <FlickrResult <TagCollection> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.tagsForPlace");

            if (String.IsNullOrEmpty(placeId) && String.IsNullOrEmpty(woeId))
            {
                throw new FlickrException("Both placeId and woeId cannot be null or empty.");
            }

            if (!String.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }
            if (!String.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            GetResponseAsync <TagCollection>(parameters, callback);
        }
예제 #4
0
 /// <summary>
 /// Adds the partial options to the passed in <see cref="Hashtable"/>.
 /// </summary>
 /// <param name="options">The options to convert to an array.</param>
 /// <param name="parameters">The <see cref="Hashtable"/> to add the option key value pairs to.</param>
 public static void PartialOptionsIntoArray(PartialSearchOptions options, Dictionary <string, string> parameters)
 {
     if (options.MinUploadDate != DateTime.MinValue)
     {
         parameters.Add("min_uploaded_date", UtilityMethods.DateToUnixTimestamp(options.MinUploadDate).ToString());
     }
     if (options.MaxUploadDate != DateTime.MinValue)
     {
         parameters.Add("max_uploaded_date", UtilityMethods.DateToUnixTimestamp(options.MaxUploadDate).ToString());
     }
     if (options.MinTakenDate != DateTime.MinValue)
     {
         parameters.Add("min_taken_date", DateToMySql(options.MinTakenDate));
     }
     if (options.MaxTakenDate != DateTime.MinValue)
     {
         parameters.Add("max_taken_date", DateToMySql(options.MaxTakenDate));
     }
     if (options.Extras != PhotoSearchExtras.None)
     {
         parameters.Add("extras", options.ExtrasString);
     }
     if (options.SortOrder != PhotoSearchSortOrder.None)
     {
         parameters.Add("sort", options.SortOrderString);
     }
     if (options.PerPage > 0)
     {
         parameters.Add("per_page", options.PerPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (options.Page > 0)
     {
         parameters.Add("page", options.Page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (options.PrivacyFilter != PrivacyFilter.None)
     {
         parameters.Add("privacy_filter", options.PrivacyFilter.ToString("d"));
     }
 }
예제 #5
0
        /// <summary>
        /// Return a list of the top 100 unique tags for a Flickr Places or Where on Earth (WOE) ID.
        /// </summary>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. (While optional, you must pass either a valid Places ID or a WOE ID.)</param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. (While optional, you must pass either a valid Places ID or a WOE ID.)</param>
        /// <param name="minUploadDate">Minimum upload date. Photos with an upload date greater than or equal to this value will be returned.</param>
        /// <param name="maxUploadDate">Maximum upload date. Photos with an upload date less than or equal to this value will be returned.</param>
        /// <param name="minTakenDate">Minimum taken date. Photos with an taken date greater than or equal to this value will be returned.</param>
        /// <param name="maxTakenDate">Maximum taken date. Photos with an taken date less than or equal to this value will be returned.</param>
        /// <returns></returns>
        public TagCollection PlacesTagsForPlace(string placeId, string woeId, DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate)
        {
            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.tagsForPlace");

            if (string.IsNullOrEmpty(placeId) && string.IsNullOrEmpty(woeId))
            {
                throw new FlickrException("Both placeId and woeId cannot be null or empty.");
            }

            if (!string.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }
            if (!string.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            return(GetResponseCache <TagCollection>(parameters));
        }
예제 #6
0
        /// <summary>
        /// Get a list of referring domains for a collection.
        /// </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.</param>
        /// <param name="collectionId">The id of the collection to get stats for. If not provided, stats for all collections will be returned.</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 domains to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <returns></returns>
        public StatDomainCollection StatsGetCollectionDomains(DateTime date, string collectionId, int page, int perPage)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.stats.getCollectionDomains");
            parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            if (!String.IsNullOrEmpty(collectionId))
            {
                parameters.Add("collection_id", UtilityMethods.CleanCollectionId(collectionId));
            }
            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 <StatDomainCollection>(parameters));
        }
예제 #7
0
        /// <summary>
        /// Return a list of your photos that have been recently created or which have been recently modified.
        /// Recently modified may mean that the photo's metadata (title, description, tags)
        /// may have been changed or a comment has been added (or just modified somehow :-)
        /// </summary>
        /// <param name="minDate">The date from which modifications should be compared.</param>
        /// <param name="extras">A list of extra information to fetch for each returned record.</param>
        /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.</param>
        /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
        /// <returns>Returns a <see cref="PhotoCollection"/> instance containing the list of photos.</returns>
        public PhotoCollection PhotosRecentlyUpdated(DateTime minDate, PhotoSearchExtras extras, int page, int perPage)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.photos.recentlyUpdated");
            parameters.Add("min_date", UtilityMethods.DateToUnixTimestamp(minDate));
            if (extras != PhotoSearchExtras.None)
            {
                parameters.Add("extras", UtilityMethods.ExtrasToString(extras));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            return(GetResponseCache <PhotoCollection>(parameters));
        }
예제 #8
0
        /// <summary>
        /// Get a list of referring domains for a photoset.
        /// </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.</param>
        /// <param name="photosetId">The id of the photoset to get stats for.
        /// If not provided, stats for all sets will be returned.</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 domains to return per page.
        /// If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void StatsGetPhotosetDomainsAsync(DateTime date, string photosetId, int page, int perPage, Action <FlickrResult <StatDomainCollection> > callback)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.stats.getPhotosetDomains");
            parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            if (!String.IsNullOrEmpty(photosetId))
            {
                parameters.Add("photoset_id", photosetId);
            }
            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));
            }

            GetResponseAsync <StatDomainCollection>(parameters, callback);
        }
        /// <summary>
        /// Get a list of favourites for the specified user.
        /// </summary>
        /// <param name="userId">The user id of the user whose favourites you wish to retrieve.</param>
        /// <param name="minFavoriteDate">Minimum date that a photo was favorited on.</param>
        /// <param name="maxFavoriteDate">Maximum date that a photo was favorited on. </param>
        /// <param name="extras">The extras to return for each photo.</param>
        /// <param name="perPage">Number of photos to include per page.</param>
        /// <param name="page">The page to download this time.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void FavoritesGetListAsync(string userId, DateTime minFavoriteDate, DateTime maxFavoriteDate,
                                          PhotoSearchExtras extras, int page, int perPage,
                                          Action <FlickrResult <PhotoCollection> > callback)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.favorites.getList");
            if (userId != null)
            {
                parameters.Add("user_id", userId);
            }
            if (minFavoriteDate != DateTime.MinValue)
            {
                parameters.Add("min_fav_date", UtilityMethods.DateToUnixTimestamp(minFavoriteDate));
            }
            if (maxFavoriteDate != DateTime.MinValue)
            {
                parameters.Add("max_fav_date", UtilityMethods.DateToUnixTimestamp(maxFavoriteDate));
            }
            if (extras != PhotoSearchExtras.None)
            {
                parameters.Add("extras", UtilityMethods.ExtrasToString(extras));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            GetResponseAsync <PhotoCollection>(parameters, callback);
        }
예제 #10
0
        /// <summary>
        /// Get a list of referrers from a given domain to a photoset.
        /// </summary>
        /// <param name="date">The date to return stats for.</param>
        /// <param name="domain">The domain to return referrers for.
        /// This should be a hostname (eg: "flickr.com") with no protocol or pathname.</param>
        /// <param name="photosetId">The photoset to return referrers for. If missing then referrers for all photosets will be returned.</param>
        /// <param name="page">The page of the results to return. Default is 1.</param>
        /// <param name="perPage">The number of referrers to return per page.
        /// The default is 25 and the maximum is 100.</param>
        /// <returns>The referrers.</returns>
        public StatReferrerCollection StatsGetPhotosetReferrers(DateTime date, string domain, string photosetId, int page, int perPage)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.stats.getPhotosetReferrers");
            parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            parameters.Add("domain", domain);
            if (!string.IsNullOrEmpty(photosetId))
            {
                parameters.Add("photoset_id", photosetId);
            }
            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 <StatReferrerCollection>(parameters));
        }
예제 #11
0
        /// <summary>
        /// Get a list of referrers from a given domain to a collection.
        /// </summary>
        /// <param name="date">The date to return stats for.</param>
        /// <param name="domain">The domain to return referrers for. This should be a hostname (eg: "flickr.com") with no protocol or pathname.</param>
        /// <param name="collectionId">The collection to return referrers for. If missing then referrers for all photosets will be returned.</param>
        /// <param name="page">The page of the results to return. Default is 1.</param>
        /// <param name="perPage">The number of referrers to return per page. The default is 25 and the maximum is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public async Task <FlickrResult <StatReferrerCollection> > StatsGetCollectionReferrersAsync(DateTime date, string domain, string collectionId, int page, int perPage)
        {
            CheckRequiresAuthentication();

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

            parameters.Add("method", "flickr.stats.getCollectionReferrers");
            parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            parameters.Add("domain", domain);
            if (!String.IsNullOrEmpty(collectionId))
            {
                parameters.Add("collection_id", collectionId);
            }
            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(await GetResponseAsync <StatReferrerCollection>(parameters));
        }
예제 #12
0
 /// <summary>
 /// Takes the various properties of this instance and adds them to a <see cref="Dictionary{K,V}"/> instanced passed in, ready for sending to Flickr.
 /// </summary>
 /// <param name="parameters">The <see cref="Dictionary{K,V}"/> to add the options to.</param>
 public void AddToDictionary(Dictionary <string, string> parameters)
 {
     if (!string.IsNullOrEmpty(UserId))
     {
         parameters.Add("user_id", UserId);
     }
     if (!string.IsNullOrEmpty(GroupId))
     {
         parameters.Add("group_id", GroupId);
     }
     if (!string.IsNullOrEmpty(Text))
     {
         parameters.Add("text", Text);
     }
     if (!string.IsNullOrEmpty(Tags))
     {
         parameters.Add("tags", Tags);
     }
     if (TagMode != TagMode.None)
     {
         parameters.Add("tag_mode", UtilityMethods.TagModeToString(TagMode));
     }
     if (!string.IsNullOrEmpty(MachineTags))
     {
         parameters.Add("machine_tags", MachineTags);
     }
     if (MachineTagMode != MachineTagMode.None)
     {
         parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(MachineTagMode));
     }
     if (MinUploadDate != DateTime.MinValue)
     {
         parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(MinUploadDate).ToString());
     }
     if (MaxUploadDate != DateTime.MinValue)
     {
         parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(MaxUploadDate).ToString());
     }
     if (MinTakenDate != DateTime.MinValue)
     {
         parameters.Add("min_taken_date", UtilityMethods.DateToMySql(MinTakenDate));
     }
     if (MaxTakenDate != DateTime.MinValue)
     {
         parameters.Add("max_taken_date", UtilityMethods.DateToMySql(MaxTakenDate));
     }
     if (Licenses.Count != 0)
     {
         var licenseArray = new List <string>();
         foreach (var license in Licenses)
         {
             licenseArray.Add(license.ToString("d"));
         }
         parameters.Add("license", String.Join(",", licenseArray.ToArray()));
     }
     if (PerPage != 0)
     {
         parameters.Add("per_page", PerPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Page != 0)
     {
         parameters.Add("page", Page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Extras != PhotoSearchExtras.None)
     {
         parameters.Add("extras", ExtrasString);
     }
     if (SortOrder != PhotoSearchSortOrder.None)
     {
         parameters.Add("sort", SortOrderString);
     }
     if (PrivacyFilter != PrivacyFilter.None)
     {
         parameters.Add("privacy_filter", PrivacyFilter.ToString("d"));
     }
     if (BoundaryBox != null && BoundaryBox.IsSet)
     {
         parameters.Add("bbox", BoundaryBox.ToString());
     }
     if (Accuracy != GeoAccuracy.None)
     {
         parameters.Add("accuracy", Accuracy.ToString("d"));
     }
     if (SafeSearch != SafetyLevel.None)
     {
         parameters.Add("safe_search", SafeSearch.ToString("d"));
     }
     if (ContentType != ContentTypeSearch.None)
     {
         parameters.Add("content_type", ContentType.ToString("d"));
     }
     if (HasGeo != null)
     {
         parameters.Add("has_geo", HasGeo.Value ? "1" : "0");
     }
     if (Latitude != null)
     {
         parameters.Add("lat", Latitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Longitude != null)
     {
         parameters.Add("lon", Longitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Radius != null)
     {
         parameters.Add("radius", Radius.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (RadiusUnits != RadiusUnit.None)
     {
         parameters.Add("radius_units", (RadiusUnits == RadiusUnit.Miles ? "mi" : "km"));
     }
     if (Contacts != ContactSearch.None)
     {
         parameters.Add("contacts", (Contacts == ContactSearch.AllContacts ? "all" : "ff"));
     }
     if (WoeId != null)
     {
         parameters.Add("woe_id", WoeId);
     }
     if (PlaceId != null)
     {
         parameters.Add("place_id", PlaceId);
     }
     if (IsCommons)
     {
         parameters.Add("is_commons", "1");
     }
     if (InGallery)
     {
         parameters.Add("in_gallery", "1");
     }
     if (IsGetty)
     {
         parameters.Add("is_getty", "1");
     }
     if (MediaType != MediaType.None)
     {
         parameters.Add("media", UtilityMethods.MediaTypeToString(MediaType));
     }
     if (GeoContext != GeoContext.NotDefined)
     {
         parameters.Add("geo_context", GeoContext.ToString("d"));
     }
     if (Faves)
     {
         parameters.Add("faves", "1");
     }
     if (PersonId != null)
     {
         parameters.Add("person_id", PersonId);
     }
     if (Camera != null)
     {
         parameters.Add("camera", Camera);
     }
     if (JumpTo != null)
     {
         parameters.Add("jump_to", JumpTo);
     }
 }
예제 #13
0
        /// <summary>
        /// Returns count of photos between each pair of dates in the list.
        /// </summary>
        /// <remarks>If you pass in DateA, DateB and DateC it returns
        /// a list of the number of photos between DateA and DateB,
        /// followed by the number between DateB and DateC.
        /// More parameters means more sets.</remarks>
        /// <param name="dates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
        /// <param name="takenDates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
        /// <returns><see cref="PhotoCountCollection"/> class instance.</returns>
        public PhotoCountCollection PhotosGetCounts(DateTime[] dates, DateTime[] takenDates)
        {
            string dateString      = null;
            string takenDateString = null;

            if (dates != null && dates.Length > 0)
            {
                Array.Sort <DateTime>(dates);
                dateString = String.Join(",", new List <DateTime>(dates).ConvertAll <string>(new Converter <DateTime, string>(delegate(DateTime d) { return(UtilityMethods.DateToUnixTimestamp(d).ToString()); })).ToArray());
            }

            if (takenDates != null && takenDates.Length > 0)
            {
                Array.Sort <DateTime>(takenDates);
                takenDateString = String.Join(",", new List <DateTime>(takenDates).ConvertAll <string>(new Converter <DateTime, string>(delegate(DateTime d) { return(UtilityMethods.DateToMySql(d).ToString()); })).ToArray());
            }

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

            parameters.Add("method", "flickr.photos.getCounts");
            if (dateString != null && dateString.Length > 0)
            {
                parameters.Add("dates", dateString);
            }
            if (takenDateString != null && takenDateString.Length > 0)
            {
                parameters.Add("taken_dates", takenDateString);
            }

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