コード例 #1
0
 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>();
                                            });
 }
コード例 #2
0
 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 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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #6
0
        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"
                }
            });
        }
コード例 #7
0
 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);
        }
コード例 #9
0
 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>();
     }));
 }
コード例 #10
0
 public Task LoadMore(SearchInstance instance, Rating rating, ResultSize resultSize)
 {
     return(Task.Run(() => { }));
 }
コード例 #11
0
 public SearchHistory(string search, ResultSize resultSize, Rating rating)
 {
     Search     = search;
     ResultSize = resultSize;
     Rating     = rating;
 }
コード例 #12
0
        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);
        }
コード例 #14
0
 public SearchHistory(string search, ResultSize resultSize, Rating rating)
 {
     Search = search;
     ResultSize = resultSize;
     Rating = rating;
 }