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