コード例 #1
0
        protected override QueryStringParametersList GetQueryStringParameters()
        {
            if (Origins == null || !Origins.Any())
            {
                throw new ArgumentException("Must specify an Origins");
            }
            if (Destinations == null || !Destinations.Any())
            {
                throw new ArgumentException("Must specify a Destinations");
            }

            var parameters = base.GetQueryStringParameters();

            parameters.Add("origins", string.Join("|", Origins));
            parameters.Add("destinations", string.Join("|", Destinations));

            if (DepartureTime != null)
            {
                parameters.Add("departure_time", DepartureTime.ToString());
            }

            return(parameters);
        }
コード例 #2
0
        private void AssignDestination()
        {
            bool vTest =
                Destinations.Any
                (
                    r =>
                    r.Key.Equals
                    (
                        AppSettingsValues.PushToDestination
                        , StringComparison.OrdinalIgnoreCase
                    )
                );

            NoOp = !vTest || NoOp;
            if (vTest)
            {
                KeyValuePair <string, List <NuGetRepository> > vDestination =
                    Destinations.FirstOrDefault
                    (
                        r =>
                        r.Key.Equals
                        (
                            AppSettingsValues.PushToDestination
                            , StringComparison.OrdinalIgnoreCase
                        )
                    );
                SelectedDestination.DestinationName = vDestination.Key;
                SelectedDestination.Repositories    = vDestination.Value;
            }
            else
            {
                ErrorContainer.Errors.Add
                    ($"Invalid destination: {AppSettingsValues.PushToDestination}");
                throw new Exception("Invalid configuration.");
            }
        }
コード例 #3
0
 public bool ContainsDestination(string destination)
 {
     return(Destinations.Any(x => x == destination));
 }
コード例 #4
0
        protected override QueryStringParametersList GetQueryStringParameters()
        {
            if (Origins == null || !Origins.Any())
            {
                throw new ArgumentException("Must specify an Origins");
            }
            if (Destinations == null || !Destinations.Any())
            {
                throw new ArgumentException("Must specify a Destinations");
            }
            if (DepartureTime != null && ArrivalTime != null)
            {
                throw new ArgumentException("Must not specify both an ArrivalTime and a DepartureTime");
            }
            if (Mode != DistanceMatrixTravelModes.transit && ArrivalTime != null)
            {
                throw new ArgumentException("Must not specify ArrivalTime for modes other than Transit");
            }
            if (Mode != DistanceMatrixTravelModes.transit && TransitRoutingPreference != null)
            {
                throw new ArgumentException("Must not specify TransitRoutingPreference for modes other than Transit");
            }
            if (Mode != DistanceMatrixTravelModes.transit && TransitModes != null && TransitModes.Length > 0)
            {
                throw new ArgumentException("Must not specify TransitModes for modes other than Transit");
            }
            if ((!(Mode == null || Mode == DistanceMatrixTravelModes.driving) || DepartureTime == null) &&
                TrafficModel != null)
            {
                throw new ArgumentException("A TrafficModel must not be specified unless the Mode is Driving and a DepartureTime is provided");
            }

            var parameters = base.GetQueryStringParameters();

            parameters.Add("origins", string.Join("|", Origins));
            parameters.Add("destinations", string.Join("|", Destinations));

            if (DepartureTime != null)
            {
                parameters.Add("departure_time", DepartureTime.ToString());
            }

            if (ArrivalTime != null)
            {
                parameters.Add("arrival_time", ArrivalTime.ToString());
            }

            if (Mode != null)
            {
                parameters.Add("mode", Mode.ToString());
            }

            if (TrafficModel != null)
            {
                parameters.Add("traffic_model", TrafficModel.ToString());
            }

            if (TransitRoutingPreference != null)
            {
                parameters.Add("transit_routing_preference", TransitRoutingPreference.ToString());
            }

            if (TransitModes != null && TransitModes.Length > 0)
            {
                parameters.Add("transit_mode", string.Join("|", TransitModes.Select(a => a.ToString())));
            }

            if (Avoid != null)
            {
                parameters.Add("avoid", Avoid.ToString());
            }

            if (Units != null)
            {
                parameters.Add("units", Units.ToString());
            }

            if (!string.IsNullOrWhiteSpace(Language))
            {
                parameters.Add("language", Language);
            }

            return(parameters);
        }