本文整理汇总了C#中Parcel.TryParseReceiverAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Parcel.TryParseReceiverAddress方法的具体用法?C# Parcel.TryParseReceiverAddress怎么用?C# Parcel.TryParseReceiverAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel.TryParseReceiverAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillInCities
private async Task<string> FillInCities(IBrowser browser, Parcel parcel, CancellationToken ct)
{
var senderCity = parcel.SenderCity ?? "Йошкар-Ола";
if (string.IsNullOrWhiteSpace(await SelectCity(browser, senderCity, "getSenderCity", "senderContext", ct)))
throw new InvalidOperationException("Can't find and choose sender city");
var receiverPossibleCities = parcel.TryParseReceiverAddress();
foreach (var receiverCity in receiverPossibleCities)
{
var deliveryPath = await SelectCity(browser, receiverCity, "getReceiverCity", "receiverContext", ct);
if (!string.IsNullOrWhiteSpace(deliveryPath))
{
return deliveryPath;
}
}
throw new InvalidOperationException("Can't find and choose receiver city");
}
示例2: SetDeliveryPath
private async Task<string> SetDeliveryPath(Parcel parcel, CancellationToken ct)
{
while (!await _browser.Select("input[name='form.cityDeliveryName']", ct))
await Task.Delay(100, ct);
var receiverPossibleCities = parcel.TryParseReceiverAddress();
var cities = new List<string>();
foreach (var receiverCity in receiverPossibleCities)
{
await _browser.Input(receiverCity, ct);
if (!await _browser.WaitForAjax(5000, ct))
throw new TimeoutException("Failed to wait for sender city setup");
cities.Clear();
var icities = (await _browser.ExecuteJs("return fragma.modules.dpdTariffs.getCities()", ct) as IList);
if (icities.Count == 0)
continue;
foreach (var c in icities)
cities.Add(c.ToString());
if (cities.Count == 1)
return cities.First();
var weight = 0;
var index = 0;
var i = 0;
foreach (var city1 in cities)
{
var newWeight = receiverCity.GetLevelOfSimilarity(city1);
if (newWeight > weight)
{
index = i;
weight = newWeight;
}
++i;
}
if (weight == 0)
continue;
await _browser.Input(cities[index], ct);
if (!await _browser.WaitForAjax(5000, ct))
throw new TimeoutException("Failed to wait for sender city setup");
return cities[index];
}
return null;
}