Beispiel #1
0
        /// <summary>
        /// Begins an asynchronous request for searching news.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        /// <param name="resultCount">The count of result itmes.</param>
        /// <param name="geo">A particular location of the news. You must supply either a city, state, country, or zip code as in "Santa Barbara" or "British Columbia" or "Peru" or "93108".</param>
        /// <param name="sortBy">The way to order results.</param>
        /// <param name="quoteId">This optional argument tells the news search system to scope search results to include only quote typed results.</param>
        /// <param name="topic">This optional argument tells the news search system to scope search results to a particular topic.</param>
        /// <param name="edition">This optional argument tells the news search system which edition of news to pull results from.</param>
        /// <param name="callback">The <see cref="AsyncCallback"/> delegate.</param>
        /// <param name="state">An object containing state information for this asynchronous request.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous request.</returns>
        public IAsyncResult BeginSearch(
            string keyword,
            int resultCount,
            string geo,
            string sortBy,
            string quoteId,
            string topic,
            string edition,
            AsyncCallback callback,
            object state)
        {
            if (keyword == null && string.IsNullOrEmpty(geo) && string.IsNullOrEmpty(topic))
            {
                throw new ArgumentNullException("keyword");
            }

            var request = new GnewsSearchRequest
            {
                Query   = keyword,
                Geo     = geo,
                SortBy  = sortBy,
                QuoteId = quoteId,
                Topic   = topic,
                Edition = edition
            };

            return(this.BeginSearch <GnewsResult>(request, resultCount, callback, state));
        }
Beispiel #2
0
        /// <summary>
        /// Search news.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        /// <param name="resultCount">The count of result itmes.</param>
        /// <param name="geo">A particular location of the news. You must supply either a city, state, country, or zip code as in "Santa Barbara" or "British Columbia" or "Peru" or "93108".</param>
        /// <param name="sortBy">The way to order results.</param>
        /// <param name="quoteId">This optional argument tells the news search system to scope search results to include only quote typed results.</param>
        /// <param name="topic">This optional argument tells the news search system to scope search results to a particular topic.</param>
        /// <param name="edition">This optional argument tells the news search system which edition of news to pull results from.</param>
        /// <returns>The result items.</returns>
        /// <remarks>Now, the max count of items Google given is <b>64</b>.</remarks>
        public IList <INewsResult> Search(
            string keyword,
            int resultCount,
            string geo,
            string sortBy,
            string quoteId,
            string topic,
            string edition)
        {
            if (keyword == null && string.IsNullOrEmpty(geo) && string.IsNullOrEmpty(topic))
            {
                throw new ArgumentNullException("keyword");
            }

            var request = new GnewsSearchRequest
            {
                Query = keyword, Geo = geo, SortBy = sortBy, QuoteId = quoteId, Topic = topic, Edition = edition
            };

            return(this.Search <GnewsResult, INewsResult>(request, resultCount));
        }
        /// <summary>
        /// Search news.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        /// <param name="resultCount">The count of result itmes.</param>
        /// <param name="geo">A particular location of the news. You must supply either a city, state, country, or zip code as in "Santa Barbara" or "British Columbia" or "Peru" or "93108".</param>
        /// <param name="sortBy">The way to order results.</param>
        /// <param name="quoteId">This optional argument tells the news search system to scope search results to include only quote typed results.</param>
        /// <param name="topic">This optional argument tells the news search system to scope search results to a particular topic.</param>
        /// <param name="edition">This optional argument tells the news search system which edition of news to pull results from.</param>
        /// <returns>The result items.</returns>
        /// <remarks>Now, the max count of items Google given is <b>64</b>.</remarks>
        public IList<INewsResult> Search(
            string keyword,
            int resultCount,
            string geo,
            string sortBy,
            string quoteId,
            string topic,
            string edition)
        {
            if (keyword == null && string.IsNullOrEmpty(geo) && string.IsNullOrEmpty(topic))
            {
                throw new ArgumentNullException("keyword");
            }

            var request = new GnewsSearchRequest
                {
                    Query = keyword, Geo = geo, SortBy = sortBy, QuoteId = quoteId, Topic = topic, Edition = edition 
                };
            return this.Search<GnewsResult, INewsResult>(request, resultCount);
        }
        /// <summary>
        /// Begins an asynchronous request for searching news.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        /// <param name="resultCount">The count of result itmes.</param>
        /// <param name="geo">A particular location of the news. You must supply either a city, state, country, or zip code as in "Santa Barbara" or "British Columbia" or "Peru" or "93108".</param>
        /// <param name="sortBy">The way to order results.</param>
        /// <param name="quoteId">This optional argument tells the news search system to scope search results to include only quote typed results.</param>
        /// <param name="topic">This optional argument tells the news search system to scope search results to a particular topic.</param>
        /// <param name="edition">This optional argument tells the news search system which edition of news to pull results from.</param>
        /// <param name="callback">The <see cref="AsyncCallback"/> delegate.</param>
        /// <param name="state">An object containing state information for this asynchronous request.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous request.</returns>
        public IAsyncResult BeginSearch(
            string keyword,
            int resultCount,
            string geo,
            string sortBy,
            string quoteId,
            string topic,
            string edition,
            AsyncCallback callback,
            object state)
        {
            if (keyword == null && string.IsNullOrEmpty(geo) && string.IsNullOrEmpty(topic))
            {
                throw new ArgumentNullException("keyword");
            }

            var request = new GnewsSearchRequest
            {
                Query = keyword,
                Geo = geo,
                SortBy = sortBy,
                QuoteId = quoteId,
                Topic = topic,
                Edition = edition
            };
            return this.BeginSearch<GnewsResult>(request, resultCount, callback, state);
        }