void DoBlock(string @operator, ConditionBlockAction action) { if (action == null) { return; } Condition item = _root.Children.Find(p => p.Name == @operator); if (item == null) { if (@operator == "$and" && _root.Children.Count == 0) { item = _root; } else { item = new Condition(@operator, ConditionTypes.Logical); } } ConditionBlock block = new ConditionBlock(item); action(block); if (@operator == "$or" && item.Children.Count > 1) { item.Children.IsArray = true; } if (item.Children.Count > 0 && item != _root) { _root.Children.Add(item); } }
public IConditionInstance Or(ConditionBlockAction action) { DoBlock("$or", action); return(this); }
public IConditionInstance Not(ConditionBlockAction action) { DoBlock("$not", action); return(this); }
public IConditionInstance And(ConditionBlockAction action) { DoBlock("$and", action); return(this); }