public QuerySearchCompletedArgs(SearchedQuery searchedQuery)
        {
            if (searchedQuery == null)
                throw new ArgumentNullException("searchedQuery");

            SearchedQuery = searchedQuery;
        }
        public void Constructor_ValidArg_SetsPublicProperty()
        {
            var page = new SearchedQuery("xbox");
            var args = new QuerySearchCompletedArgs(page);

            Assert.AreSame(page, args.SearchedQuery);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     async method to send query to bing
        /// </summary>
        /// <param name="queryToSearch">pass query related info to bing</param>
        /// <returns></returns>
        private async Task QuerySearch(QueryToSearch queryToSearch)
        {
            await Task.Run(() =>
                {
                    //Fire event when search is about to start
                    FireQuerySearchStartingEventAsync(queryToSearch);

                    var searchedQuery = new SearchedQuery(queryToSearch.Query);
                    try
                    {
                        DataServiceQuery<ExpandableSearchResult> result = base.Composite("web", queryToSearch.Query,
                                                                                         null, null, null, null, null,
                                                                                         null, null, null, null, null,
                                                                                         null, null, null);
                        IEnumerable<ExpandableSearchResult> webResults = result.Execute();

                        foreach (ExpandableSearchResult r in webResults)
                        {
                            searchedQuery.Result.Add(new QueryResult {ID = r.ID, WebTotal = r.WebTotal});
                        }
                    }
                    catch (Exception ex)
                    {
                        searchedQuery.Exception = ex;
                        FireQuerySearchExceptionEventAsync(searchedQuery);
                    }

                    FireQuerySearchCompletedEventAsync(searchedQuery);
                });
        }
        public void Cunstructor_Empty()
        {
            var query = new SearchedQuery("test");

            var args = new QuerySearchExceptionArgs(query);

            Assert.AreSame(query, args.SearchedQuery);
        }
 public QuerySearchExceptionArgs(SearchedQuery searchedQuery)
 {
     if (searchedQuery == null)
     {
         searchedQuery = new SearchedQuery(null);
         searchedQuery.Exception = new ArgumentNullException("searchedQuery");
     }
     SearchedQuery = searchedQuery;
 }
Exemplo n.º 6
0
 private void FireQuerySearchExceptionEventAsync(SearchedQuery searchedQuery)
 {
     OnQuerySearchExceptionAsync(new QuerySearchExceptionArgs(searchedQuery));
 }
Exemplo n.º 7
0
 private void FireQuerySearchCompletedEventAsync(SearchedQuery searchedQuery)
 {
     OnQuerySearchCompletedAsync(new QuerySearchCompletedArgs(searchedQuery));
 }