* QueryCompositionalCondition.cs: chore

* QueryEqualCondition.cs:
* QueryOperationCondition.cs:
oneRain 2019-09-17 16:31:08 +08:00
parent bd47c2e44e
commit 1823dd974b
3 changed files with 13 additions and 19 deletions

View File

@ -222,11 +222,7 @@ namespace LeanCloud.Storage.Internal {
} }
public void AddCondition(string key, string op, object value) { public void AddCondition(string key, string op, object value) {
QueryOperationCondition cond = new QueryOperationCondition { QueryOperationCondition cond = new QueryOperationCondition(key, op, value);
Key = key,
Op = op,
Value = value
};
AddCondition(cond); AddCondition(cond);
} }

View File

@ -2,8 +2,8 @@
namespace LeanCloud.Storage.Internal { namespace LeanCloud.Storage.Internal {
internal class QueryEqualCondition : IQueryCondition { internal class QueryEqualCondition : IQueryCondition {
string key; readonly string key;
object value; readonly object value;
public QueryEqualCondition(string key, object value) { public QueryEqualCondition(string key, object value) {
this.key = key; this.key = key;

View File

@ -2,29 +2,27 @@
namespace LeanCloud.Storage.Internal { namespace LeanCloud.Storage.Internal {
internal class QueryOperationCondition : IQueryCondition { internal class QueryOperationCondition : IQueryCondition {
public string Key { readonly string key;
get; set; readonly string op;
} readonly object value;
public string Op { public QueryOperationCondition(string key, string op, object value) {
get; set; this.key = key;
} this.op = op;
this.value = value;
public object Value {
get; set;
} }
public bool Equals(IQueryCondition other) { public bool Equals(IQueryCondition other) {
if (other is QueryOperationCondition otherCond) { if (other is QueryOperationCondition otherCond) {
return Key == otherCond.Key && Op == otherCond.Op; return key == otherCond.key && op == otherCond.op;
} }
return false; return false;
} }
public IDictionary<string, object> ToJSON() { public IDictionary<string, object> ToJSON() {
return new Dictionary<string, object> { return new Dictionary<string, object> {
{ Key, new Dictionary<string, object> { { key, new Dictionary<string, object> {
{ Op, Value } { op, value }
} } } }
}; };
} }