FlickrNet.Flickr.PhotosGetAllContexts C# (CSharp) Method

PhotosGetAllContexts() public method

Get all the contexts (group, set and photostream 'next' and 'previous' pictures) for a photo.
public PhotosGetAllContexts ( string photoId ) : AllContexts
photoId string The photo id of the photo to get the contexts for.
return AllContexts
        public AllContexts PhotosGetAllContexts(string photoId)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.photos.getAllContexts");
            parameters.Add("photo_id", photoId);

            FlickrNet.Response response = GetResponseCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                AllContexts contexts = new AllContexts(response.AllElements);
                return contexts;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }

Usage Example

Exemplo n.º 1
0
        public async Task <string> GetMetadata(string path)
        {
            string photoId = path.Split('/')[1];

            var info     = _flickr.PhotosGetInfo(photoId);
            var exif     = _flickr.PhotosGetExif(photoId);
            var contexts = _flickr.PhotosGetAllContexts(photoId);

            JObject j = new JObject();

            j.Add("DateLastUpdated", info.DateLastUpdated);
            j.Add("DatePosted", info.DatePosted);
            j.Add("DateTaken", info.DateTaken);
            j.Add("DateUploaded", info.DateUploaded);
            j.Add("Description", info.Description);
            j.Add("HasPeople", info.HasPeople);
            j.Add("IsPublic", info.IsPublic);
            j.Add("License", info.License.ToString());
            j.Add("Latitude", info.Location?.Latitude);
            j.Add("Longitude", info.Location?.Longitude);
            j.Add("Title", info.Title);
            j.Add("IsFamily", info.IsFamily);
            j.Add("IsFavorite", info.IsFavorite);
            j.Add("IsFriend", info.IsFriend);
            j.Add("Rotation", info.Rotation);
            j.Add("WebUrl", info.WebUrl);
            j.Add("Media", Enum.GetName(typeof(MediaType), info.Media));
            j.Add("SafetyLevel", Enum.GetName(typeof(SafetyLevel), info.SafetyLevel));
            j.Add("Tags", new JArray(info.Tags.Select(t => t.TagText).ToArray()));
            j.Add("Urls", new JArray(info.Urls.Select(t => t.Url).ToArray()));
            j.Add("Notes", new JArray(info.Notes.Select(t => t.NoteText).ToArray()));
            j.Add("ViewCount", info.ViewCount);

            j.Add("Groups", new JArray(contexts.Groups.Select(t => t.Title).ToArray()));
            j.Add("Sets", new JArray(contexts.Sets.Select(t => t.Title).ToArray()));


            exif.ToList().ForEach(e =>
            {
                j.Add(e.TagSpace + "." + e.Tag, e.CleanOrRaw);
            });

            return(await Task.FromResult(j.ToString()));
        }
Flickr