本文整理匯總了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);
}
}
}
}