当前位置: 首页>>代码示例>>C#>>正文


C# Parcel.TryParseReceiverAddress方法代码示例

本文整理汇总了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");
		}
开发者ID:FragmaYOla,项目名称:TariffMeter,代码行数:18,代码来源:SPSRTariffsProvider.cs

示例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;
		}
开发者ID:FragmaYOla,项目名称:TariffMeter,代码行数:47,代码来源:DPDTariffsProvider.cs


注:本文中的Parcel.TryParseReceiverAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。