Exemple #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()));
        }
Exemple #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);
        }
Exemple #3
0
 public static Boolean TryParseGeoFence(this String Text, out GeoFence GeoLocation)
 => GeoFence.TryParse(JObject.Parse(Text), out GeoLocation);
Exemple #4
0
 public static Boolean TryParseJSON(String Text, out GeoFence GeoFence)
 => TryParse(JObject.Parse(Text), out GeoFence);