Exemplo n.º 1
0
        /// <summary>
        /// This Method Will Search In Google The Best Result Using The Search Text Provided In The
        /// ISearchWithGoogle Item, And Will Store The Result Inside The GoogleData Object.
        /// </summary>
        /// <param name="itemForSearch">The Item That Has The Option To Be Searched By Google</param>
        /// <returns>The GoogleData Object Fetched With The Best Result</returns>
        public static GoogleData GetGoogleData(string searchText)
        {
            GoogleData googleData = new GoogleData(searchText);
            Thread     t          = new Thread(() => { googleData.GoogleDataValue = GoogleSearcher.GetBestGoogleAnswer(googleData); });

            t.Start();
            t.Join();
            return(googleData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This Method Will Search In Google, The Best Result Using The Search Text Provided In The
        /// ISearchWithGoogle Items, And Will Store The Result Inside The GoogleData Objects.
        /// </summary>
        /// <param name="itemsForSearch">The Items That Has The Option To Be Searched By Google</param>
        /// <returns>The GoogleData Object List Fetched With The Best Result</returns>
        public static IEnumerable <GoogleData> GetGoogleDataList(IEnumerable <ISearchWithGoogle> itemsForSearch)
        {
            List <GoogleData> googleDataList = new List <GoogleData>();
            var dicOfItemsToSearch           = itemsForSearch.GroupBy(t => t.TextToSearch);

            GoogleSearcher.OnGoogleAPIIsNotSupportedAnymore += OnGoogleAPIIsNotSupportedAnymore;
            foreach (var itemForSearch in dicOfItemsToSearch)
            {
                // Here I will use Threading to get all the Google data for all the items.
                GoogleData googleData = GetGoogleData(itemForSearch.Key);
                googleDataList.Add(googleData);
            }
            return(googleDataList);
        }