sharpfellows.toolkit /Samples/Commands/Bingo.BingSearch/BingSearchEngine.cs

Language C# Lines 44
MD5 Hash f0feef7ee6172bc648537dd1633e9e0f Estimated Cost $728 (why?)
Repository https://bitbucket.org/suhas_28/sharpfellows.toolkit View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using System.Linq;
using Bingo.BingSearch.Bing;
using Bingo.Common;

namespace Bingo.BingSearch
{
    /// <summary>
    /// Implementation of the web search engine using Bing
    /// </summary>
    public class BingSearchEngine : ISearchEngine
    {
        /// <summary>
        /// Searches the web using the query provided.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public IEnumerable<SearchResult> DoSearch(string query)
        {
            using (var service = new LiveSearchPortTypeClient())
            {
                var request = new SearchRequest
                                  {
                                      AppId = "F703173CD4C405522296261437A850508F4A6E14",
                                      Sources = new SourceType[] {SourceType.Web},
                                      Query = query
                                  };

                var response = service.Search(request);

                return
                    response.Web.Results.Select(
                        result =>
                        new SearchResult
                        {
                            Url = result.Url,
                            Title = result.Title,
                            Description = result.Description
                        });
            }
        }
    }
}
Back to Top