當前位置: 首頁>>代碼示例>>C#>>正文


C# RestClient.GetTaskAsync方法代碼示例

本文整理匯總了C#中RestSharp.RestClient.GetTaskAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# RestClient.GetTaskAsync方法的具體用法?C# RestClient.GetTaskAsync怎麽用?C# RestClient.GetTaskAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RestSharp.RestClient的用法示例。


在下文中一共展示了RestClient.GetTaskAsync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BindData

        public async Task<List<ClosestPointModel>> BindData(string adress)
        {
           
            var client = new RestClient("https://geocode-maps.yandex.ru/1.x/?format=json&lang=uk_Ua&geocode="+adress);

            var request = new RestRequest("resource/", Method.GET);
            
            var data = await client.GetTaskAsync<GeocodeModel.RootObject>(request);

            var latitude = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos[0];
            var longitude = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos[1];
            
            RepositoryHolder holder = new RepositoryHolder();

            ClosestPointMapper mapper = new ClosestPointMapper();
            var adressRepository = holder.AdressRepository;
           List<ClosestPointModel> resultData =
                adressRepository.
                    Fetch().
                    Select(p => mapper.EntityToUI(p, latitude, longitude))
                    .OrderBy(z => z.FakeLatitude).
                    ThenBy(z => z.FakeLongitude).
                    Take(20).ToList();

           
            return resultData;
        }
開發者ID:GoGo228,項目名稱:FINREpo,代碼行數:27,代碼來源:ClosestPointBinder.cs

示例2: GetDeviceData

        private async Task GetDeviceData(TokenResponseDto token)
        {
            var client = new RestClient("https://api.netatmo.com");
            var request = new RestRequest("/api/getstationsdata");
            request.AddQueryParameter("access_token", token.AccessToken);

            var data = await client.GetTaskAsync<StationDataResponseDto>(request);

            if (data?.Body?.Devices == null)
            {
                return;
            }

            lock (_deviceLock)
            {
                foreach (var dataDevice in data.Body.Devices)
                {
                    var station = dataDevice.StationName;
                    dataDevice.BatteryPercent = 100;

                    UpdateDevice(station, dataDevice);

                    if (dataDevice.Modules == null)
                    {
                        continue;
                    }

                    foreach (var module in dataDevice.Modules)
                    {
                        UpdateDevice(station, module);
                    }
                }
            }
        }
開發者ID:xpressive-websolutions,項目名稱:Xpressive.Home.ProofOfConcept,代碼行數:34,代碼來源:NetatmoGateway.cs


注:本文中的RestSharp.RestClient.GetTaskAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。