コード例 #1
0
        public static IEnumerable Search(SearchQuery query) {
            List<SearchResult> searchResults = new List<SearchResult>();

            List<SearchProviderBase> searchProviders = GetSearchProviders();

            if ((query == null) || (String.IsNullOrEmpty(query.Query)))
                return searchResults;

            foreach (SearchProviderBase searchProvider in searchProviders) {
                SearchResult[] providerSearchResults = null;
                providerSearchResults = searchProvider.Search(query);

                if ((providerSearchResults != null) && (providerSearchResults.Length > 0))
                    searchResults.AddRange(providerSearchResults);
            }

            return searchResults;
        }
コード例 #2
0
        public override SearchResult[] Search(SearchQuery query) {
            List<SearchResult> searchResults = new List<SearchResult>();

            int startOffset = 0;
            MSNSearchService msnSearchService = new MSNSearchService();

            SearchRequest searchRequest = new SearchRequest();
            int arraySize = 1;
            SourceRequest[] sr = new SourceRequest[arraySize];
            sr[0] = new SourceRequest();
            sr[0].Source = SourceType.Web;
            sr[0].Offset = startOffset;

            String searchPrefix = String.IsNullOrEmpty(_siteDomainName) ? "" : "site:" + _siteDomainName + " ";

            searchRequest.Query = searchPrefix + query.Query;
            searchRequest.Requests = sr;
            searchRequest.AppID = _appID;
            searchRequest.CultureInfo = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;

            SearchResponse searchResponse = msnSearchService.Search(searchRequest);

            foreach (SourceResponse sourceResponse in searchResponse.Responses) {
                Result[] sourceResults = sourceResponse.Results;
                foreach (Result sourceResult in sourceResults) {
                    SearchResult searchResult = new SearchResult();

                    if (!String.IsNullOrEmpty(sourceResult.Title))
                        searchResult.Title = sourceResult.Title;

                    if (!String.IsNullOrEmpty(sourceResult.Description))
                        searchResult.Description = sourceResult.Description;

                    if (!String.IsNullOrEmpty(sourceResult.Url))
                        searchResult.Url = sourceResult.Url;

                    searchResults.Add(searchResult);
                }
            }

            return searchResults.ToArray();
        }
コード例 #3
0
 public static IEnumerable Search(String query) {
     SearchQuery searchQuery = new SearchQuery();
     searchQuery.Query = query;
     return Search(searchQuery);
 }
コード例 #4
0
 public virtual SearchResult[] Search(SearchQuery query) {
     return null;
 }