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


C# LocalDate.PlusWeeks方法代码示例

本文整理汇总了C#中LocalDate.PlusWeeks方法的典型用法代码示例。如果您正苦于以下问题:C# LocalDate.PlusWeeks方法的具体用法?C# LocalDate.PlusWeeks怎么用?C# LocalDate.PlusWeeks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LocalDate的用法示例。


在下文中一共展示了LocalDate.PlusWeeks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchSimplified

        private static async Task SearchSimplified()
        {
            var scanner = new Scanner(ConfigurationManager.AppSettings["apiKey"]);
            var from = (await scanner.QueryLocation("London")).First();
            var to = (await scanner.QueryLocation("New York")).First();
            
            var now = new LocalDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            var outboundDate = now.PlusWeeks(1);
            var inboundDate = now.PlusWeeks(2);

            //Query flights
            var itineraries = await scanner.QueryFlight(
                new FlightQuerySettings(
                    new FlightRequestSettings(from, to, outboundDate, inboundDate),
                    new FlightResponseSettings(SortType.Price, SortOrder.Ascending)), 
                WriteToDebug());

            itineraries = itineraries
                .Take(5)
                .ToList();

            if (!itineraries.Any())
            {
                WriteLine("No flights");
                return;
            }

            foreach (var itinerary in itineraries)
            {
                WriteItinerary(itinerary, Currency.Default);
            }

            WriteSeparator();

            //Query bookings (note, this is forbidden by SkyScanner, should only query exact booking details if a user requests them)
            var bookingQueryTasks = itineraries.Select(scanner.QueryBooking);
            var bookingResults = (await Task.WhenAll(bookingQueryTasks))
                .OrderBy(response =>
                    response.BookingOptions
                        .Select(option => option.BookingItems.Sum(item => item.Price))
                        .Min());

            foreach (var response in bookingResults)
            {
                WriteBookingResult(response, Currency.Default);
            }
        }
开发者ID:jochenvanwylick,项目名称:SkyScanner,代码行数:47,代码来源:Program.cs

示例2: PlusWeeks_Simple

 public void PlusWeeks_Simple()
 {
     LocalDate start = new LocalDate(2011, 4, 2);
     LocalDate expectedForward = new LocalDate(2011, 4, 23);
     LocalDate expectedBackward = new LocalDate(2011, 3, 12);
     Assert.AreEqual(expectedForward, start.PlusWeeks(3));
     Assert.AreEqual(expectedBackward, start.PlusWeeks(-3));
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalDateTest.Pseudomutators.cs

示例3: 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)
//.........这里部分代码省略.........
开发者ID:jochenvanwylick,项目名称:SkyScanner,代码行数:101,代码来源:Program.cs


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