private object _encodeSubQueries(object value) { if (!(value is IDictionary)) { return(value); } Dictionary <string, object> jsonBefore = (Dictionary <string, object>)value; //Dictionary<string , object> jsonAfter = null;//foreachの中でjsonBeforeに値を追加しているため永遠とforeachが回るのを防ぐ Dictionary <string, object> jsonAfter = new Dictionary <string, object> (); foreach (KeyValuePair <string, object> pair in jsonBefore) { if (pair.Value is NCMBQuery <NCMBObject> ) { NCMBQuery <NCMBObject> query = (NCMBQuery <NCMBObject>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBUser> ) { NCMBQuery <NCMBUser> query = (NCMBQuery <NCMBUser>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBRole> ) { NCMBQuery <NCMBRole> query = (NCMBQuery <NCMBRole>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBInstallation> ) { NCMBQuery <NCMBInstallation> query = (NCMBQuery <NCMBInstallation>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBPush> ) { NCMBQuery <NCMBPush> query = (NCMBQuery <NCMBPush>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is IDictionary) { jsonAfter [pair.Key] = _encodeSubQueries(pair.Value); } else { jsonAfter [pair.Key] = pair.Value; //前 } } return(jsonAfter); }
private object _encodeSubQueries(object value) { if (!(value is IDictionary)) { return(value); } Dictionary <string, object> jsonBefore = (Dictionary <string, object>)value; //Dictionary<string , object> jsonAfter = null;//foreachの中でjsonBeforeに値を追加しているため永遠とforeachが回るのを防ぐ Dictionary <string, object> jsonAfter = new Dictionary <string, object> (); foreach (KeyValuePair <string, object> pair in jsonBefore) { //元々はNCMBQuery<T>でまとめて出来たがinQueryでサブクエリQuery<NCMBObjcet>とメインクエリ<NCMBUser>が来た時さばけないため //それぞれの型で対応する。NCMBFile等追加するときは要注意 if (pair.Value is NCMBQuery <NCMBObject> ) { NCMBQuery <NCMBObject> query = (NCMBQuery <NCMBObject>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBUser> ) { NCMBQuery <NCMBUser> query = (NCMBQuery <NCMBUser>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is NCMBQuery <NCMBRole> ) { NCMBQuery <NCMBRole> query = (NCMBQuery <NCMBRole>)pair.Value; Dictionary <string, object> realData = query._getFindParams(); realData ["where"] = realData ["where"]; jsonAfter [pair.Key] = realData; } else if (pair.Value is IDictionary) { jsonAfter [pair.Key] = _encodeSubQueries(pair.Value); } else { jsonAfter [pair.Key] = pair.Value; //前 } } return(jsonAfter); }