public string ToURIString()
        {
            string uri = "origins=";

            foreach (var orig in Origins)
            {
                if (orig != Origins.First())
                {
                    uri += "|";
                }
                uri += orig.ToLocationString();
            }

            uri += "&destinations=";
            foreach (var orig in Destinations)
            {
                if (orig != Destinations.First())
                {
                    uri += "|";
                }
                uri += orig.ToLocationString();
            }

            if (string.IsNullOrEmpty(Language))
            {
                uri += "&language=" + Language;
            }

            if (Mode != null)
            {
                uri += "&mode=" + Mode.ToString();
            }

            if (Avoid != null)
            {
                uri += "&avoid=" + Avoid.ToString();
            }

            if (string.IsNullOrWhiteSpace(Region))
            {
                uri += "&region=" + Region;
            }

            if (TrafficModel != null)
            {
                uri += "&trafficmodel=" + TrafficModel.ToString();
            }

            if (TransitMode != null)
            {
                uri += "&transit=" + TransitMode.ToString();
            }

            if (preference != null)
            {
                uri += "&transit_routing_preference=" + preference.ToString();
            }

            return(uri);
        }
        }        //end method

        /// <summary>
        /// Create URI for quering
        /// </summary>
        /// <returns></returns>
        internal Uri ToUri()
        {
            this.EnsureSensor(true);

            var qsb = new Internal.QueryStringBuilder()
                      .Append("origins", WaypointsToUri(waypointsOrigin))
                      .Append("destinations", WaypointsToUri(WaypointsDestination))
                      .Append("mode", Mode.ToString())
                      .Append("language", Language)
                      .Append("units", Units.ToString())
                      .Append("sensor", (Sensor.Value ? "true" : "false"))
                      .Append("avoid", Avoid.ToString());

            var url = "json?" + qsb.ToString();

            return(new Uri(url, UriKind.Relative));
        }
Пример #3
0
        public void WriteLocalData()
        {
            string ret = "";

            ret += version.ToString() + '|';
            ret += NHpLower.ToString() + '|';
            ret += NMpLower.ToString() + '|';
            ret += (0).ToString() + '|'; //MHPLower
            ret += BuyDrug.ToString() + '|';
            ret += PickEqp.ToString() + '|';
            ret += PickMat.ToString() + '|';
            ret += EqpProc.ToString() + '|';

            ret += PickEqp_cailiao.ToString() + '|';
            ret += PickPet_cailiao.ToString() + '|';
            ret += PickWing_cailiao.ToString() + '|';
            ret += PickSummon_cailiao.ToString() + '|';
            ret += PickDrugs.ToString() + '|';
            ret += PickGold.ToString() + '|';
            ret += PickOther.ToString() + '|';

            ret += EqpType.ToString() + '|';
            ret += Skills[0].ToString() + '|';
            ret += Skills[1].ToString() + '|';
            ret += Skills[2].ToString() + '|';
            ret += Skills[3].ToString() + '|';
            ret += (1).ToString() + '|'; //Scope  // Modified
            ret += Avoid.ToString() + '|';
            ret += AutoPK.ToString() + '|';
            ret += StoneRespawn.ToString() + '|';
            ret += GoldRespawn.ToString() + '|';
            ret += RespawnLimit.ToString() + '|';
            ret += RespawnUpBound.ToString();

            FileMgr.saveString(FileMgr.TYPE_AUTO, "setting", ret);
        }
Пример #4
0
        protected override QueryStringParametersList GetQueryStringParameters()
        {
            if (string.IsNullOrWhiteSpace(Origin))
            {
                throw new ArgumentException("Must specify an Origin");
            }
            if (string.IsNullOrWhiteSpace(Destination))
            {
                throw new ArgumentException("Must specify a Destination");
            }
            if (!Enum.IsDefined(typeof(AvoidWay), Avoid))
            {
                throw new ArgumentException("Invalid enumeration value for 'Avoid'");
            }
            if (!Enum.IsDefined(typeof(TravelMode), TravelMode))
            {
                throw new ArgumentException("Invalid enumeration value for 'TravelMode'");
            }

            if (TravelMode == TravelMode.Transit && (DepartureTime == default(DateTime) && ArrivalTime == default(DateTime)))
            {
                throw new ArgumentException("You must set either DepatureTime or ArrivalTime when TravelMode = Transit");
            }

            var parameters = base.GetQueryStringParameters();

            parameters.Add("origin", Origin);
            parameters.Add("destination", Destination);
            parameters.Add("mode", TravelMode.ToString().ToLower());

            if (Alternatives)
            {
                parameters.Add("alternatives", "true");
            }

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

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

            if (Waypoints != null && Waypoints.Any())
            {
                IEnumerable <string> waypoints;

                if (OptimizeWaypoints)
                {
                    const string optimizeWaypoints = "optimize:true";

                    waypoints = new string[] { optimizeWaypoints }.Concat(Waypoints);
                }
                else
                {
                    waypoints = Waypoints;
                }

                parameters.Add("waypoints", string.Join("|", waypoints));
            }

            if (ArrivalTime != default(DateTime))
            {
                parameters.Add("arrival_time", UnixTimeConverter.DateTimeToUnixTimestamp(ArrivalTime).ToString(CultureInfo.InvariantCulture));
            }

            if (DepartureTime != default(DateTime))
            {
                parameters.Add("departure_time", UnixTimeConverter.DateTimeToUnixTimestamp(DepartureTime).ToString(CultureInfo.InvariantCulture));
            }

            return(parameters);
        }
Пример #5
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);
        }