本文整理汇总了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;
}
示例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);
}
}
}
}