示例#1
0
        protected override QueryStringParametersList GetQueryStringParameters()
        {
            if (Location == null && string.IsNullOrWhiteSpace(Address))
            {
                throw new ArgumentException("Location OR Address is required");
            }

            var parameters = base.GetQueryStringParameters();

            if (Location != null)
            {
                parameters.Add("latlng", Location.ToString());
            }
            else
            {
                parameters.Add("address", Address);
            }

            if (Bounds != null && Bounds.Any())
            {
                parameters.Add("bounds", string.Join("|", Bounds.AsEnumerable()));
            }

            if (!string.IsNullOrWhiteSpace(Region))
            {
                parameters.Add("region", Region);
            }

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

            return(parameters);
        }
示例#2
0
        protected override QueryStringParametersList GetQueryStringParameters()
        {
            bool hasAddress = !string.IsNullOrWhiteSpace(Address);
            bool hasPlaceId = !string.IsNullOrWhiteSpace(PlaceId);

            if (!hasAddress && Location == null && !Components.Exists && !hasPlaceId)
            {
                throw new ArgumentException("Address, Location, Components OR PlaceId is required");
            }

            var parameters = base.GetQueryStringParameters();

            if (Location != null)
            {
                parameters.Add(_latlng, Location.ToString());
            }

            if (hasAddress)
            {
                parameters.Add(_address, Address);
            }

            if (hasPlaceId)
            {
                parameters.Add(_placeId, PlaceId);
            }

            if (Components.Exists)
            {
                string components = Components.Build();
                parameters.Add(_components, components);
            }

            if (Bounds != null && Bounds.Any())
            {
                parameters.Add(_bounds, string.Join("|", Bounds.AsEnumerable()));
            }

            if (!string.IsNullOrWhiteSpace(Region))
            {
                parameters.Add(_region, Region);
            }

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

            return(parameters);
        }