private static ILocation GenerateLocation(MapContext <object> context) { object value = context.Value; if (value == null) { return(new Location()); } if (value is ILocation location) { return(location); } if (value is GeoCoordinate geoCoordinate) { if (geoCoordinate.IsUnknown) { return(new Location()); } return(new Location(geoCoordinate.Latitude, geoCoordinate.Longitude)); } if (value is DbGeography dbGeography) { return(new Location(dbGeography.Latitude, dbGeography.Longitude)); } if (value is Tuple <double?, double?> tupleNullable) { return(new Location(tupleNullable.Item1, tupleNullable.Item2)); } if (value is Tuple <double, double> tuple) { return(new Location(tuple.Item1, tuple.Item2)); } var type = value.GetType(); if (!_types.TryGetValue(type, out Tuple <PropertyInfo, PropertyInfo> tupleProperties)) { lock (_types) { if (!_types.TryGetValue(type, out tupleProperties)) { PropertyInfo latitudePropertyInfo = type.GetProperty("Latitude", BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); PropertyInfo longitudePropertyInfo = type.GetProperty("Longitude", BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); tupleProperties = Tuple.Create <PropertyInfo, PropertyInfo>(latitudePropertyInfo, longitudePropertyInfo); _types.Add(type, tupleProperties); } } } return(new Location(GetLocationValue(tupleProperties.Item1, value), GetLocationValue(tupleProperties.Item2, value))); }
internal Map(MapContext <TValue> context, string name) : base(context, name, true) { Context = context; }
internal ImageMap(MapContext <string> context, string name) : base(context, name) { }
internal GeographicMapMap(MapContext <object> context, string name) : base(context, name) { }