示例#1
0
        public virtual string BuildCaml(ComplexExpression complexExpression)
        {
            if (complexExpression.Expressions.Count == 1)
            {
                return(BuildCaml(complexExpression.Expressions[0]));
            }
            if (complexExpression.Expressions.Count == 0)
            {
                throw new InvalidOperationException("Отсутствуют дочерние выражения");
            }
            if (complexExpression.Operator == Operator.Nothing)
            {
                throw new InvalidOperationException("Недопустимое значение оператора");
            }

            string template = "<{0}>{1}{2}</{0}>";
            string result   = BuildCaml(complexExpression.Expressions[0]);

            for (int index = 1; index < complexExpression.Expressions.Count; index++)
            {
                result = string.Format(CultureInfo.CurrentCulture, template, complexExpression.Operator.ToString(), result, BuildCaml(complexExpression.Expressions[index]));
            }

            return(result);
        }
示例#2
0
        public static ComplexExpression CreateExpression(IExpression expr1, IExpression expr2, Operator op)
        {
            ComplexExpression expr = new ComplexExpression();

            expr.Operator = op;
            expr.Expressions.Add(expr1);
            expr.Expressions.Add(expr2);
            return(expr);
        }
 public static ComplexExpression operator *(MembershipFilter filter1, IExpression filter2)
 {
     return(ComplexExpression.CreateExpression(filter1, filter2, Operator.And));
 }
示例#4
0
 public static ComplexExpression operator +(Filter filter1, Filter filter2)
 {
     return(ComplexExpression.CreateExpression(filter1, filter2, Operator.Or));
 }