private Condition <T> AddClause(ClauseElement clause) { Condition <T> parent = stack.Peek(); if (parent.GetType() == typeof(ListCondition <T>)) { ListCondition <T> list = (ListCondition <T>)parent; if (list.IsClosed()) { throw new QueryException(String.Format("Invalid Stack State: List condition is already closed. [type={0}]", list.GetType().FullName)); } if (clause.GetType() != typeof(ClauseValue)) { throw new QueryException(String.Format("Invalid Clause: Expected Value clause. [type={0}]", clause.GetType().FullName)); } list.AddValue((ClauseValue)clause); return(list); } else if (parent.GetType() == typeof(BasicCondition <T>)) { BasicCondition <T> condition = (BasicCondition <T>)parent; if (condition.IsClosed()) { throw new QueryException(String.Format("Invalid Stack State: List condition is already closed. [type={0}]", condition.GetType().FullName)); } if (condition.LeftElement == null) { condition.LeftElement = clause; } else { condition.RightElement = clause; } return(condition); } throw new QueryException(String.Format("Invalid Stack State: Cannot add clause. [type={0}]", parent.GetType().FullName)); }
public Condition <T> Operation(ClauseElement clause) { Contract.Requires(clause != null); return(AddClause(clause)); }