public SearchResponse Search(SearchRequest request) { SearchResponse cacheRespoinse = GetFromCache(request.Query); if (cacheRespoinse != null) { return cacheRespoinse; } request.AppId = appID; using (ManualResetEvent signal = new ManualResetEvent(false)) { MsnSyncContext context = new MsnSyncContext(signal); AsyncSearch(request, MsnSyncCallback, context); signal.WaitOne(); if (context.error != null) { throw context.error; } return context.data; } }
SearchRequest CreateSimpleRequest(string query) { SearchRequest searchRequest = new SearchRequest(); searchRequest.AppId = appID; searchRequest.Version = "2.0"; searchRequest.Market = cultureInfo; searchRequest.Query = XmlHelper.XmlEncoding(query); searchRequest.Sources = new SourceType[] { SourceType.Web }; searchRequest.Web = new WebRequest(); searchRequest.Web.Count = (uint)snippetCount; searchRequest.Web.CountSpecified = true; searchRequest.Web.Offset = 0; searchRequest.Web.OffsetSpecified = true; searchRequest.Web.Options = new WebSearchOption[] { WebSearchOption.DisableHostCollapsing, WebSearchOption.DisableQueryAlterations }; return searchRequest; }
/// <remarks/> public void SearchAsync(SearchRequest Request, object userState) { if ((this.SearchOperationCompleted == null)) { this.SearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOperationCompleted); } this.InvokeAsync("Search", new object[] { Request}, this.SearchOperationCompleted, userState); }
public void AsyncSearch(SearchRequest request, WaitCallback callback, object userState) { SearchResponse cacheRespoinse = GetFromCache(request.Query); if (cacheRespoinse != null) { SnippetGatherState sgs = new SnippetGatherState(); sgs.result = cacheRespoinse; sgs.userState = userState; ThreadPool.QueueUserWorkItem(callback, sgs); return; } request.AppId = appID; SnippetGatherState state = new SnippetGatherState(); state.request = request; state.userState = userState; state.userCallback = callback; state.internalCallback = SnippetGatherCallback; jobQueue.EnqueueJob(state); }
/// <remarks/> public void SearchAsync(SearchRequest Request) { this.SearchAsync(Request, null); }
/// <remarks/> public System.IAsyncResult BeginSearch(SearchRequest Request, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("Search", new object[] { Request}, callback, asyncState); }
public SearchResponse Search(SearchRequest Request) { object[] results = this.Invoke("Search", new object[] { Request}); return ((SearchResponse)(results[0])); }
/// <remarks/> public void SearchAsync(SearchRequest parameters) { this.SearchAsync(parameters, null); }
public SearchResponse Search(SearchRequest parameters) { object[] results = this.Invoke("Search", new object[] { parameters}); return ((SearchResponse)(results[0])); }