Ejemplo n.º 1
0
            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);
                }
            }
Ejemplo n.º 2
0
 public IConditionInstance Or(ConditionBlockAction action)
 {
     DoBlock("$or", action);
     return(this);
 }
Ejemplo n.º 3
0
 public IConditionInstance Not(ConditionBlockAction action)
 {
     DoBlock("$not", action);
     return(this);
 }
Ejemplo n.º 4
0
 public IConditionInstance And(ConditionBlockAction action)
 {
     DoBlock("$and", action);
     return(this);
 }