예제 #1
0
        /// <summary>
        /// Initializes static members of the <see cref="AirportDataProvider"/> class.
        /// </summary>
        static AirportDataProvider()
        {
            var data = new List<Airport>();
            using (var txtReader = new StringReader(Resources.Airports))
            using (
                var reader = new CsvReader(txtReader, false) { DefaultParseErrorAction = ParseErrorAction.AdvanceToNextLine, SkipEmptyLines = true })
            {
                while (reader.ReadNextRecord())
                {
                    string iata = reader[4];
                    if (string.IsNullOrEmpty(iata))
                    {
                        continue;
                    }

                    string name = reader[1], city = reader[2], country = reader[3];
                    float latitude = float.Parse(reader[6], NamingRule.NumberCulture), longitude = float.Parse(reader[7], NamingRule.NumberCulture);
                    var airport = new Airport(name, city, country, iata, latitude, longitude);
                    data.Add(airport);
                }
            }

            data.Sort((a, b) => a.ToString().CompareTo(b.ToString()));
            Airports = data.AsReadOnly();
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TravelRoute"/> class.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="departure">
        /// The departure.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public TravelRoute(long id, Airport departure, Airport destination)
            : this()
        {
            if (departure == null)
            {
                throw new ArgumentException("Departure cannot be empty");
            }

            if (destination == null)
            {
                throw new ArgumentException("Destination cannot be empty");
            }

            this.Id = id;
            this.Departure = departure;
            this.Destination = destination;
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterCondition"/> class.
 /// </summary>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="minDuration">
 /// The min duration.
 /// </param>
 /// <param name="maxDuration">
 /// The max duration.
 /// </param>
 /// <param name="maxPrice">
 /// The max price.
 /// </param>
 /// <param name="departureDate">
 /// The departure date.
 /// </param>
 /// <param name="returnDate">
 /// The return date.
 /// </param>
 /// <param name="operators">
 /// The operators.
 /// </param>
 public FilterCondition(
     Airport origin,
     Airport destination,
     int minDuration,
     int maxDuration,
     int maxPrice,
     DateTime departureDate,
     DateTime returnDate,
     Dictionary<string, bool> operators)
 {
     this.Departure = origin;
     this.Destination = destination;
     this.MinDuration = minDuration;
     this.MaxDuration = maxDuration;
     this.MaxPrice = maxPrice;
     this.DepartureDate = departureDate;
     this.ReturnDate = returnDate;
     this.Operators = operators;
 }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FlightFareRequest"/> class.
        /// </summary>
        /// <param name="departure">
        /// The departure.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="departureDate">
        /// The departure date.
        /// </param>
        /// <param name="returnDate">
        /// The return date.
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public FlightFareRequest(Airport departure, Airport destination, DateTime departureDate, DateTime returnDate)
        {
            if (departure == null)
            {
                throw new ArgumentException("Departure cannot be null");
            }

            if (destination == null)
            {
                throw new ArgumentException("Destination cannot be null");
            }

            if (departureDate.IsUndefined())
            {
                throw new ArgumentException("Departure date is not defined");
            }

            this.Departure = departure;
            this.Destination = destination;
            this.DepartureDate = departureDate;
            this.ReturnDate = returnDate;
        }
예제 #5
0
 /// <summary>
 /// The enqueue.
 /// </summary>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="departureDate">
 /// The departure date.
 /// </param>
 /// <param name="returnDate">
 /// The return date.
 /// </param>
 public void Enqueue(Airport origin, Airport destination, DateTime departureDate, DateTime returnDate)
 {
     var newRequest = new FareMonitorRequest(origin, destination, departureDate, returnDate);
     this.Enqueue(newRequest);
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FareMonitorRequest"/> class.
 /// </summary>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="departureDate">
 /// The departure date.
 /// </param>
 /// <param name="returnDate">
 /// The return date.
 /// </param>
 public FareMonitorRequest(Airport origin, Airport destination, DateTime departureDate, DateTime returnDate)
     : base(origin, destination, departureDate, returnDate)
 {
 }