FlickrNet.Flickr.PhotosetsGetContext C# (CSharp) Method

PhotosetsGetContext() public method

Gets the context of the specified photo within the photoset.
public PhotosetsGetContext ( string photoId, string photosetId ) : Context
photoId string The photo id of the photo in the set.
photosetId string The id of the set.
return Context
        public Context PhotosetsGetContext(string photoId, string photosetId)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.photosets.getContext");
            parameters.Add("photo_id", photoId);
            parameters.Add("photoset_id", photosetId);

            FlickrNet.Response response = GetResponseCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                Context c = new Context();
                c.Count = response.ContextCount.Count;
                c.NextPhoto = response.ContextNextPhoto;
                c.PreviousPhoto = response.ContextPrevPhoto;

                return c;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// this method will get photograph info and context information (previous/next thumbnail URLs) given its unique image ID
        /// </summary>
        /// <param name="imageUID">unique ID of image</param>
        /// <param name="setUID">unique ID of set</param>
        /// <returns>Photograph Entity</returns>
        public Photograph GetFlickrPhotoContextByImageUID(string imageUID, string setUID)
        {
            try
            {
                Photograph photo = new Photograph();

                //HACK NOTE: for some reaon GetFlickrPhotographByImageUID wasn't working here so I decided to get the whole set
                List <Photograph> photoList = GetPhotoSetPhotoListBySetID(setUID);

                //get the correct photo out of the collection
                foreach (Photograph p in photoList)
                {
                    if (p.ImageUID == imageUID)
                    {
                        //photo = GetFlickrPhotographByImageUID(imageUID);
                        photo = p;
                        break;
                    }
                }

                //add attributes to photo meta data
                Context photosetContext = flickr.PhotosetsGetContext(imageUID, setUID);
                if (photosetContext.PreviousPhoto.PhotoId != "0")
                {
                    photo.PreviousThumbnailURL = photosetContext.PreviousPhoto.ThumbnailUrl;
                    photo.PreviousImageUID     = photosetContext.PreviousPhoto.PhotoId;
                }
                if (photosetContext.NextPhoto.PhotoId != "0")
                {
                    photo.NextThumbnailURL = photosetContext.NextPhoto.ThumbnailUrl;
                    photo.NextImageUID     = photosetContext.NextPhoto.PhotoId;
                }
                return(photo);
            }
            catch (Exception ex)
            {
                System.IO.StreamWriter sw = System.IO.File.AppendText(ConfigurationManager.AppSettings["ErrorLogPath"].ToString() + "SkiChairErrorLogFile.txt");
                try
                {
                    string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, "Error: " + ex.Message);
                    sw.WriteLine(logLine);
                }
                finally
                {
                    sw.Close();
                }
                return(null);
            }
        }
Flickr