public Task<List<ImageResult>> Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { return Task.Run<List<ImageResult>>(() => { return new List<ImageResult>(); }); }
public async Task LoadMore(SearchInstance instance, Rating rating, ResultSize resultSize) { var imagesToAdd = await Search(instance.Query, rating, resultSize, instance.Images.Count + 1); foreach (var image in imagesToAdd) { instance.Images.Add(image); } }
public async Task<List<ImageResult>> Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { var images = new List<ImageResult>(); var context = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Data.ashx/Bing/Search")); context.Credentials = new NetworkCredential(_api, _api); var result = await context.Image(search, "en-US", rating, resultSize, offset).ExecuteAsync(); images.AddRange(result.ToList()); return images; }
private static int GetIntFromResultSize(ResultSize resultSize) { switch (resultSize) { default: case ResultSize.Twenty: return(20); case ResultSize.Forty: return(50); case ResultSize.OneHundred: return(100); } }
public Task<List<ImageResult>> Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { if (ReturnNoResults) { return Task.Run(() => new List<ImageResult>()); } Searches.Add(new SearchHistory(search, resultSize, rating)); return Task.Run(() => new List<ImageResult>() { new ImageResult() { Title = "Sample Image", MediaUrl = "http://example.com/sample.jpg" } }); }
public Task LoadMore(SearchInstance instance, Rating rating, ResultSize resultSize) { return Task.Run(() => { }); }
public static DataServiceQuery <ImageResult> Image(this BingSearchContainer container, string searchText, string market, Rating rating, ResultSize resultSize, int offset) { var ratingKey = Enum.GetName(typeof(Rating), rating); var pageSize = GetIntFromResultSize(resultSize); var query = container.Image(searchText, market, ratingKey, null, null, null) .AddQueryOption("$top", pageSize) .AddQueryOption("$skip", offset); return(query); }
public Task <List <ImageResult> > Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { return(Task.Run <List <ImageResult> >(() => { return new List <ImageResult>(); })); }
public Task LoadMore(SearchInstance instance, Rating rating, ResultSize resultSize) { return(Task.Run(() => { })); }
public SearchHistory(string search, ResultSize resultSize, Rating rating) { Search = search; ResultSize = resultSize; Rating = rating; }
public Task <List <ImageResult> > Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { if (ReturnNoResults) { return(Task.Run(() => new List <ImageResult>())); } Searches.Add(new SearchHistory(search, resultSize, rating)); return(Task.Run(() => new List <ImageResult>() { new ImageResult() { Title = "Sample Image", MediaUrl = "http://example.com/sample.jpg" } })); }
public async Task <List <ImageResult> > Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0) { var images = new List <ImageResult>(); var context = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Data.ashx/Bing/Search")); context.Credentials = new NetworkCredential(_api, _api); var result = await context.Image(search, "en-US", rating, resultSize, offset).ExecuteAsync(); images.AddRange(result.ToList()); return(images); }