public static async Task<List<FlickrPhotoResult>> SearchAsync(string searchTerm) { HttpClient client = new HttpClient(); FlickrSearchUrl url = new FlickrSearchUrl(searchTerm); List<FlickrPhotoResult> list = new List<FlickrPhotoResult>(); using (HttpResponseMessage response = await client.GetAsync(new Uri(url.ToString(), UriKind.Absolute))) { if (response.IsSuccessStatusCode) { String contentxml = await response.Content.ReadAsStringAsync(); XElement xml = XElement.Parse(contentxml); list = ( from p in xml.DescendantsAndSelf("photo") select new FlickrPhotoResult(p) ).ToList(); } } return (list); }
public static async Task <List <FlickrPhotoResult> > SearchAsync(string searchTerm) { HttpClient client = new HttpClient(); FlickrSearchUrl url = new FlickrSearchUrl(searchTerm); List <FlickrPhotoResult> list = new List <FlickrPhotoResult>(); using (HttpResponseMessage response = await client.GetAsync(new Uri(url.ToString(), UriKind.Absolute))) { if (response.IsSuccessStatusCode) { String contentxml = await response.Content.ReadAsStringAsync(); XElement xml = XElement.Parse(contentxml); list = ( from p in xml.DescendantsAndSelf("photo") select new FlickrPhotoResult(p) ).ToList(); } } return(list); }