Ejemplo n.º 1
0
        /// <summary>
        /// Return a JSON representation of the given GeoLocation.
        /// </summary>
        /// <param name="GeoFence">A geographical location.</param>
        /// <param name="JPropertyKey">The name of the JSON property key to use.</param>
        public static JProperty ToJSON(this GeoFence GeoFence, String JPropertyKey)
        {
            //if (GeoLocation == default(GeoFence))
            //    return null;

            return(new JProperty(JPropertyKey,
                                 GeoFence.ToJSON()));
        }
Ejemplo n.º 2
0
        public static Boolean TryParse(JObject JSON, out GeoFence GeoFence)
        {
            var type   = JSON["type"]?.Value <String>();
            var radius = JSON["radius"]?.Value <String>();

            if (type != null && type == "circle" && radius.IsNeitherNullNorEmpty())
            {
                try
                {
                    GeoFence = new GeoFence(Meter.Parse(radius));
                    return(true);
                }
                catch (Exception)
                { }
            }

            GeoFence = default;
            return(false);
        }
Ejemplo n.º 3
0
 public static Boolean TryParseGeoFence(this String Text, out GeoFence GeoLocation)
 => GeoFence.TryParse(JObject.Parse(Text), out GeoLocation);
Ejemplo n.º 4
0
 public static Boolean TryParseJSON(String Text, out GeoFence GeoFence)
 => TryParse(JObject.Parse(Text), out GeoFence);