コード例 #1
0
        public static string GetStringValue(this BingCountry value)
        {
            string output = null;
            Type   type   = value.GetType();

            FieldInfo fi = type.GetRuntimeField(value.ToString());

            StringValueAttribute[] attrs = fi.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[];
            if (attrs.Length > 0)
            {
                output = attrs[0].Value;
            }

            return(output);
        }
コード例 #2
0
        private async void SearchButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!await Tools.CheckInternetConnectionAsync())
            {
                return;
            }

            if (string.IsNullOrEmpty(SearchText.Text))
            {
                return;
            }

            BingCountry  country  = (BingCountry)(CntryList?.SelectedItem ?? BingCountry.UnitedStates);
            BingLanguage language = (BingLanguage)(Languages?.SelectedItem ?? BingLanguage.English);

            BingQueryType queryType;

            switch (QueryType.SelectedIndex)
            {
            case 1:
                queryType = BingQueryType.News;
                break;

            default:
                queryType = BingQueryType.Search;
                break;
            }

            var searchConfig = new BingSearchConfig
            {
                Country   = country,
                Language  = language,
                Query     = SearchText.Text,
                QueryType = queryType
            };

            // Gets an instance of BingService that is able to load search results incrementally.
#pragma warning disable CS0618 // Type or member is obsolete
            var collection = BingService.GetAsIncrementalLoading(searchConfig, 50);
#pragma warning restore CS0618 // Type or member is obsolete
            collection.OnStartLoading = async() => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = true; });

            collection.OnEndLoading = async() => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = false; });

            ListView.ItemsSource = collection;
        }
コード例 #3
0
        public async void GetItems()
        {
            string      bingQueryParam          = "Windows App Studio";
            BingCountry bingCountrySelectedItem = BingCountry.UnitedStates;
            int         maxRecordsParam         = 20;

            Items.Clear();
            var bingDataProvider = new BingDataProvider();
            var config           = new BingDataConfig()
            {
                Query = bingQueryParam, Country = bingCountrySelectedItem
            };

            var items = await bingDataProvider.LoadDataAsync(config, maxRecordsParam);

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
コード例 #4
0
        private async void SearchButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!await Tools.CheckInternetConnectionAsync())
            {
                return;
            }

            if (string.IsNullOrEmpty(SearchText.Text))
            {
                return;
            }

            BingCountry  country  = (BingCountry)(Countries?.SelectedItem ?? BingCountry.UnitedStates);
            BingLanguage language = (BingLanguage)(Languages?.SelectedItem ?? BingLanguage.English);

            BingQueryType queryType;

            switch (QueryType.SelectedIndex)
            {
            case 1:
                queryType = BingQueryType.News;
                break;

            default:
                queryType = BingQueryType.Search;
                break;
            }

            Shell.Current.DisplayWaitRing = true;
            var searchConfig = new BingSearchConfig
            {
                Country   = country,
                Language  = language,
                Query     = SearchText.Text,
                QueryType = queryType
            };

            ListView.ItemsSource = await BingService.Instance.RequestAsync(searchConfig, 50);

            Shell.Current.DisplayWaitRing = false;
        }
コード例 #5
0
 /// <summary>
 /// Converts between country code and country name.
 /// </summary>
 /// <param name="value">BingCountry enumeration.</param>
 /// <returns>Returns country code.</returns>
 public static string GetStringValue(this BingCountry value)
 {
     return(GetStringValue((Enum)value));
 }
コード例 #6
0
 public static string GetStringValue(this BingCountry value)
 {
     return(Toolkit.Services.Core.ExtensionMethods.GetStringValue((Toolkit.Services.Bing.BingCountry)value));
 }