Esempio n. 1
0
 public bool IsPossibleType(GraphQLObjectType type)
 {
     if (PossibleTypeNames == null)
     {
         PossibleTypeNames = Types.Aggregate(
             ImmutableDictionary <string, bool> .Empty,
             (dict, possibleType) => dict.Add(possibleType.Name, true));
     }
     return(PossibleTypeNames[type.Name]);
 }
        public List <ClosestGooglePlaceResponse> Get()
        {
            var closestPlaces = new List <ClosestGooglePlaceResponse>();

            if (!string.IsNullOrEmpty(PostCode))
            {
                var postcodeData = GetResponseString($"http://api.postcodes.io/postcodes/{PostCode}");
                postcodeData.Wait();
                var postcode = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(postcodeData.Result);

                Latitude  = float.Parse(postcode.result.latitude.ToString());
                Longitude = float.Parse(postcode.result.longitude.ToString());
            }

            var types = Types?.Aggregate("", (current, type) => current + (type + "|")) ?? "";
            var names = Names?.Aggregate("", (current, type) => current + (type + " ")) ?? "";

            string url = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={Latitude},{Longitude}&radius=500&types={types}&name={names}&keyword={Keyword}&key={APIKey}";

            if (Opennow)
            {
                url += "opennow";
            }
            var googlePlacesResponse = GetResponseString(url);

            googlePlacesResponse.Wait();
            var googlePlaces = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(googlePlacesResponse.Result);

            if (googlePlaces.results.Count <= 0)
            {
                return(closestPlaces);
            }

            foreach (var googlePlace in googlePlaces.results)
            {
                var closestPlace = new ClosestGooglePlaceResponse
                {
                    Name      = googlePlace.name?.ToString(),
                    Latitude  = float.Parse(googlePlace.geometry.location.lat.ToString()),
                    Longitude = float.Parse(googlePlace.geometry.location.lng.ToString()),
                    Icon      = googlePlace.icon?.ToString(),
                    Vicinity  = googlePlace.vicinity?.ToString(),
                    Rating    = googlePlace.rating?.ToString(),
                };
                closestPlace.SetDistanceFrom(Latitude, Longitude);

                closestPlaces.Add(closestPlace);
            }

            return(closestPlaces);
        }
Esempio n. 3
0
        /// <summary>
        ///   Returns a hash code for this instance.
        /// </summary>
        /// <returns> A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. </returns>
        public override int GetHashCode()
        {
            unchecked {
                if (Types.Length > 16)
                {
                    return(Types.Length.GetHashCode());
                }

                var tReturn = Types.Aggregate(1, (current, type) => (current * 397) ^ type.GetHashCode());

                if (InformalInterface != null)
                {
                    tReturn = InformalInterface.Aggregate(tReturn, (current, type) => (current * 397) ^ type.GetHashCode());
                }
                return(tReturn);
            }
        }
Esempio n. 4
0
 public override int GetHashCode()
 {
     return(arrayOrType == null ? 0 : Types.Aggregate(0, (acum, type) => acum ^ type.GetHashCode()));
 }
 public override int GetHashCode()
 {
     return(Module.MetadataToken * 1000000349 + Names.Aggregate(Types.Aggregate(0, (current, t) => current * 314159265 + t.GetHashCode()), (current, t) => current * 271828459 + t.GetHashCode()));
 }
Esempio n. 6
0
 internal string TypeQuery(string paramName)
 {
     return(Types.Count == 0
         ? ""
         : Types.Aggregate("", (current, type) => current + (paramName + "=" + type + "&")));
 }
Esempio n. 7
0
 public override string ToString()
 {
     return($"{nameof(DoubleGenericNameKey)}-{Name}-{Types.Aggregate("", (x, y) => x + "" + y.ToString())}-{DependentTypes.Aggregate("", (x, y) => x + "" + y.ToString())}");
 }