コード例 #1
0
ファイル: Scanner.cs プロジェクト: Sansalk/SF_Repo
        /// <summary>
        /// The Live Pricing Service (flight query) returns all the flights available for a specific route and
        /// date (or single date for one-way searches).
        /// </summary>
        /// <param name="flightQuerySettings">Settings for the query</param>
        /// <param name="interimResultCallback">The callback that is called when interim results are recieved</param>
        /// <returns>The collection of itineraries from SkyScanner</returns>
        public async Task <List <Itinerary> > QueryFlight(
            FlightQuerySettings flightQuerySettings,
            Action <InterimChangeSet <Itinerary> > interimResultCallback,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var interimResultHandler = new InterimResultProvider <FlightResponse, Itinerary>();

            var flightService = new Flight(_apiKey, flightQuerySettings);

            return(await _executionStrategy.Execute(async() =>
            {
                var pinger = await flightService.SendQuery(cancellationToken);

                if (interimResultCallback != null)
                {
                    pinger.OnInterimResultsRecieved += (sender, args) =>
                    {
                        interimResultCallback(interimResultHandler.Calculate(args));
                    };
                }

                var response = await pinger.SendQuery(cancellationToken);
                return response.Itineraries;
            }, cancellationToken));
        }
コード例 #2
0
ファイル: Scanner.cs プロジェクト: Sansalk/SF_Repo
 public async Task <List <Itinerary> > QueryFlight(FlightQuerySettings flightQuerySettings,
                                                   CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await QueryFlight(flightQuerySettings, null, cancellationToken));
 }
コード例 #3
0
ファイル: Flight.cs プロジェクト: Sansalk/SF_Repo
 public Flight(string apiKey, FlightQuerySettings querySettings)
     : base(apiKey, querySettings.FlightRequest)
 {
     _querySettings = querySettings;
 }