public NCMBObject Set(string key, NCMBGeoPoint value) { if (_objects.ContainsKey(key)) { _objects.Remove(key); } _objects.Add(key, value); return(this); }
public NCMBQuery WithinSquare(string name, NCMBGeoPoint southWestVertex, NCMBGeoPoint northEastVertex) { var box = new JObject(); var ary = new JArray(); ary.Add(southWestVertex.ToJson()); ary.Add(northEastVertex.ToJson()); box.Add("$box", ary); return(this.SetOperand(name, box, "$within")); }
public void Sets(JObject query) { foreach (KeyValuePair <string, JToken> key in query) { if (key.Key == "__type") { continue; } if (key.Key == "className") { continue; } switch (key.Value.Type) { case JTokenType.String: this.Set(key.Key, (string)key.Value); break; case JTokenType.Integer: this.Set(key.Key, (int)key.Value); break; case JTokenType.Boolean: this.Set(key.Key, (Boolean)key.Value); break; case JTokenType.Date: this.Set(key.Key, (DateTime)key.Value); break; case JTokenType.Array: this.Set(key.Key, (JArray)key.Value); break; case JTokenType.Null: this._fields[key.Key] = null; break; default: var obj = (JObject)key.Value; if (obj.ContainsKey("__type") && ((string)obj["__type"]) == "Date") { this.Set(key.Key, DateTime.Parse((string)obj["iso"])); } else if (obj.ContainsKey("__type") && ((string)obj["__type"]) == "Object") { var ChildObject = new NCMBObject((string)obj["className"]); ChildObject.Sets((JObject)obj); this.Set(key.Key, ChildObject); } else if (obj.ContainsKey("__type") && ((string)obj["__type"]) == "Relation") { // Do nothing } else if (obj.ContainsKey("__type") && ((string)obj["__type"]) == "GeoPoint") { var data = (JObject)key.Value; var geo = new NCMBGeoPoint((double)data["latitude"], (double)data["longitude"]); this.Set(key.Key, geo); } else if (key.Key == "acl") { var acl = new NCMBAcl(); acl.Sets((JObject)key.Value); this.SetAcl(acl); } else { this.Set(key.Key, (JObject)key.Value); } break; } } }
public NCMBQuery WithinRadians(string name, NCMBGeoPoint value, double maxDistance) { this.SetOperand(name, value.ToJson(), "$nearSphere"); this.where[name]["$maxDistanceInRadians"] = maxDistance; return(this); }
public NCMBQuery Near(string name, NCMBGeoPoint value) { return(SetOperand(name, value.ToJson(), "$nearSphere")); }