本文整理汇总了C#中Scanner.QueryMarket方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.QueryMarket方法的具体用法?C# Scanner.QueryMarket怎么用?C# Scanner.QueryMarket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.QueryMarket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchDetailed
private static async Task SearchDetailed()
{
//Initialize Scanner
var scanner = new Scanner(
ConfigurationManager.AppSettings["apiKey"],
RetryExecutionStrategy.Default);
//Query locales
var locales = await scanner.QueryLocale();
var currentLocale = locales.FirstOrDefault(locale => locale.Name.StartsWith("English"));
if (currentLocale == null)
{
WriteLine(ErrorColor, "Couldn't find locale, using default instead");
currentLocale = Locale.Default;
}
//Query markets
var markets = await scanner.QueryMarket(currentLocale);
var currentMarket = markets.FirstOrDefault(market => market.Name == "Switzerland");
if (currentMarket == null)
{
WriteLine(ErrorColor, "Couldn't find market, using default instead");
currentMarket = Market.Default;
}
//Query currencies
var currencies = await scanner.QueryCurrency();
var currentCurrency = currencies.FirstOrDefault(currency => currency.Code == "CHF");
if (currentCurrency == null)
{
WriteLine(ErrorColor, "Couldn't find currency, using default instead");
currentCurrency = Currency.Default;
}
//Query location
const string fromPlaceName = "London";
var from = (await scanner.QueryLocation(new LocationAutosuggestSettings(fromPlaceName,
LocationAutosuggestQueryType.Query, currentMarket, currentCurrency, currentLocale))).First();
if (from == null)
{
WriteLine(ErrorColor, "Couldn't find '{0}'", fromPlaceName);
return;
}
//Query destination location
const string toPlaceName = "New York";
var to = (await scanner.QueryLocation(new LocationAutosuggestSettings(toPlaceName,
LocationAutosuggestQueryType.Query, currentMarket, currentCurrency, currentLocale))).FirstOrDefault();
if (to == null)
{
WriteLine(ErrorColor, "Couldn't find '{0}'", toPlaceName);
return;
}
//Setup flight search settings
var flightResponseSettings = new FlightResponseSettings(
sortOrder: SortOrder.Ascending,
sortType: SortType.Price,
maxStops: 2,
maxDuration: 14 * 60,
outboundDepartureStartTime: new LocalTime(08, 0, 0),
outboundDepartureEndTime: new LocalTime(12, 0, 0),
inboundDepartureStartTime: new LocalTime(08, 0, 0),
inboundDepartureEndTime: new LocalTime(18, 30, 0)
);
var now = new LocalDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
var outboundDate = now.PlusWeeks(1);
var inboundDate = now.PlusWeeks(2);
Write("Flights from ");
Write(ImportantColor, from.PlaceName);
Write(" to ");
WriteLine(ImportantColor, to.PlaceName);
Write(" on ");
Write(ImportantColor, outboundDate.ToString("d", CultureInfo.InvariantCulture));
Write(" and back on ");
WriteLine(ImportantColor, inboundDate.ToString("d", CultureInfo.InvariantCulture));
//Query flights
var itineraries = await scanner.QueryFlight(
new FlightQuerySettings(
new FlightRequestSettings(from, to, outboundDate, inboundDate, 1,
currency: currentCurrency, marketCountry: currentMarket, locale: currentLocale),
flightResponseSettings), WriteToDebug());
itineraries = itineraries
.Take(5)
.ToList();
if (!itineraries.Any())
{
WriteLine("No flights");
return;
}
foreach (var itinerary in itineraries)
//.........这里部分代码省略.........