Exemplo n.º 1
0
        public override void ExecuteSearch(string searchCriteria, string domain, Action<string[]> callbackHandler)
        {
            string domainSpecificSearchCriteria = searchCriteria.Trim();

            // Not everything needs a domain qualifier - BING and Google being the primary cases. Only add the domain if required, this will
            // prevent BING from searching MS docs no one cares about.
            if (!String.IsNullOrEmpty(domain))
            {
                domainSpecificSearchCriteria += String.Format(" site:{0}", domain);
            }

            SearchRequest searchRequest = new SearchRequest
            {
                Adult = AdultOption.Off,
                AppId = ApiKey,
                Market = "en-US",
                Query = domainSpecificSearchCriteria,
                Sources = new[] { SourceType.Web },
                Version = "2.2",
                Web = new WebRequest { Count = 1 }
            };

            _searchBroker.SearchAsync(searchRequest, callbackHandler);
        }
Exemplo n.º 2
0
 /// <remarks/>
 public void SearchAsync(SearchRequest parameters, object userState) {
     if ((this.SearchOperationCompleted == null)) {
         this.SearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOperationCompleted);
     }
     this.InvokeAsync("Search", new object[] {
                 parameters}, this.SearchOperationCompleted, userState);
 }
Exemplo n.º 3
0
 /// <remarks/>
 public void SearchAsync(SearchRequest parameters) {
     this.SearchAsync(parameters, null);
 }
Exemplo n.º 4
0
 public SearchResponse Search(SearchRequest parameters) {
     object[] results = this.Invoke("Search", new object[] {
                 parameters});
     return ((SearchResponse)(results[0]));
 }