Exemple #1
0
        public ViewModelReactive2()
        {
            #region scenario 1

            //var textChangedSequence = Observable.FromEventPattern<PropertyChangedEventArgs>(this,
            //    nameof(PropertyChanged));

            //var throttledTextChangedSequence = textChangedSequence
            //    .Where(a => a.EventArgs.PropertyName == nameof(EnteredSearchQuery))
            //    .Select(a => EnteredSearchQuery)
            //    .DistinctUntilChanged()
            //    .Throttle(TimeSpan.FromSeconds(.5));

            #endregion

            #region scenario 2

            var throttledTextChangedSequence = this.GetPropertyAsObservable(() => EnteredSearchQuery)
                                               .DistinctUntilChanged()
                                               .Throttle(TimeSpan.FromSeconds(.5));

            #endregion

            var result = from qry in throttledTextChangedSequence
                         from images in SearchDataService.Search(qry).TakeUntil(throttledTextChangedSequence)
                         select images?.Select(a => a.thumb_url);

            throttledTextChangedSequence.ObserveOn(
                SynchronizationContext.Current).Subscribe(e => UpdateList(null));

            result.ObserveOn(
                SynchronizationContext.Current).Subscribe(UpdateList);
        }
        public void TestCombineRetrieveSuburbURL()
        {
            SearchDataService s        = new SearchDataService();
            string            postcode = "2000";
            string            expected = "2000/api.xml";
            string            result   = s.CombineRetrieveSuburbURL(postcode);

            Assert.AreEqual(expected, result);
        }
        public void TestGetSuburbByPostcode()
        {
            SearchDataService s        = new SearchDataService();
            string            url      = "http://api.epostcodes.com.au/api/codes/2762/api.xml";
            List <string>     expected = new List <string> {
                "Schofields"
            };
            List <string> result = s.GetSuburbByPostcode(url);

            CollectionAssert.AreEqual(expected, result);  //test array
        }
        public void TestCombineConfirmedCaseURL()
        {
            //test ConfigurationManager.AppSettings, need to add below in <appSettings>
            //<add key="ConfirmedCaseAPIEndpoint" value="whatever"/>
            SearchDataService s        = new SearchDataService();
            string            postcode = "2000";
            string            expected = "&q=2000";
            string            result   = s.CombineConfirmedCasesDetailsURL(postcode);

            Assert.AreEqual(expected, result);
        }
Exemple #5
0
        private async void DoSearch(CancellationToken token)
        {
            try
            {
                token.ThrowIfCancellationRequested();

                await Task.Delay(500, token);

                var result = await SearchDataService.SearchAsync(EnteredSearchQuery, token);

                token.ThrowIfCancellationRequested();

                Results = result?.Select(a => a.thumb_url).ToList();
            }
            catch (TaskCanceledException)
            {
            }
        }
        private void DoReactive()
        {
            var textChangedSequence =
                Observable.FromEventPattern <TextChangedEventArgs>(SearchBox,
                                                                   nameof(SearchBox.TextChanged));

            var throttledTextChangedSequence =
                textChangedSequence.Select(x => ((TextBox)x.Sender).Text)
                .DistinctUntilChanged()
                .Throttle(TimeSpan.FromSeconds(.5));

            var result = (from qry in throttledTextChangedSequence
                          from images in SearchDataService.Search(qry)
                          .TakeUntil(throttledTextChangedSequence)
                          select images);

            result.ObserveOn(SynchronizationContext.Current).Subscribe(
                (e) => ViewModel.Results = e?.Select(a => a.thumb_url).ToList());
        }
Exemple #7
0
        public List <AbisMonitor.Domain.AbisDeviceSimple> GetAbisDeviceSimpleList()
        {
            string queryString = @"SELECT
	bts.DataNum,
	device.DeviceName,
  device.DeviceNum,
	bts.PortNum,
	device.IPAddress,
	bts.BTS_Name,
	bts.SlotNum
FROM
	mtbtstable bts
Inner JOIN mtabisdevicetable device ON bts.DeviceNum = device.DataNum
GROUP BY
	device.DeviceName,bts.BTS_Name
ORDER BY
  device.DeviceNum,bts.PortNum,bts.SlotNum;";
            var    list        = SearchDataService.SearchData <AbisDeviceSimple>(queryString);

            return(list == null ? null : list.ToList());
        }
Exemple #8
0
 protected override async Task OnInitializedAsync()
 {
     searchData = await SearchDataService.GetSearchDataAsync();
 }