Exemplo n.º 1
0
 public ReTranslatorFromCaml(IReAnalyzer analyzerForWhere, IReAnalyzer analyzerForOrderBy,
     IReAnalyzer analyzerForGroupBy, IReAnalyzer analyzerForViewFields)
 {
     this.analyzerForWhere = analyzerForWhere;
     this.analyzerForOrderBy = analyzerForOrderBy;
     this.analyzerForGroupBy = analyzerForGroupBy;
     this.analyzerForViewFields = analyzerForViewFields;
 }
Exemplo n.º 2
0
 public ReTranslatorFromCaml(IReAnalyzer analyzerForWhere, IReAnalyzer analyzerForOrderBy,
                             IReAnalyzer analyzerForGroupBy, IReAnalyzer analyzerForViewFields)
 {
     this.analyzerForWhere      = analyzerForWhere;
     this.analyzerForOrderBy    = analyzerForOrderBy;
     this.analyzerForGroupBy    = analyzerForGroupBy;
     this.analyzerForViewFields = analyzerForViewFields;
 }
Exemplo n.º 3
0
        private LambdaExpression translateWhere(IReAnalyzer analyzer, string tag)
        {
            if (analyzer == null)
            {
                return(null);
            }
            if (!analyzer.IsValid())
            {
                throw new IncorrectCamlException(tag);
            }
            var operation = analyzer.GetOperation();
            var expr      = operation.ToExpression();

            return(Expression.Lambda(expr, Expression.Parameter(typeof(SPListItem), ReflectionHelper.CommonParameterName)));
        }
Exemplo n.º 4
0
        private LambdaExpression translateArrayOperation(IReAnalyzer analyzer, string tag)
        {
            if (analyzer == null)
            {
                return(null);
            }
            if (!analyzer.IsValid())
            {
                throw new IncorrectCamlException(tag);
            }
            var operation = analyzer.GetOperation();

            if (!(operation is ArrayOperation))
            {
                throw new CamlAnalysisException("ArrayOperation is expected");
            }

            int operandsCount = ((ArrayOperation)operation).OperandsCount;

            if (operandsCount == 0)
            {
                throw new CamlAnalysisException(
                          "ArrayOperation doesn't contain operands. There should be at least one operand");
            }

            var expr = operation.ToExpression();

            // this is important to specify the type of returning value explicitly in generic, becase otherwise
            // it will determine type by itself and it will be incorrect for ArrayOperation with orderings.
            // I.e. it will be Func<SPListItem, Camlex+Desc>, instead of Func<SPListItem,object>. In turn
            // it will cause exception in ReLinker, because parameter of type Func<SPListItem, Camlex+Desc>
            // can not be passed to the method OrderBy(Expression<Func<SPListItem, object>> expr);
            if (operandsCount == 1)
            {
                return(Expression.Lambda <Func <SPListItem, object> >(expr,
                                                                      Expression.Parameter(typeof(SPListItem),
                                                                                           ReflectionHelper.CommonParameterName)));
            }

            return(Expression.Lambda <Func <SPListItem, object[]> >(expr,
                                                                    Expression.Parameter(typeof(SPListItem),
                                                                                         ReflectionHelper.CommonParameterName)));
        }
Exemplo n.º 5
0
 private LambdaExpression translateWhere(IReAnalyzer analyzer, string tag)
 {
     if (analyzer == null)
     {
         return null;
     }
     if (!analyzer.IsValid())
     {
         throw new IncorrectCamlException(tag);
     }
     var operation = analyzer.GetOperation();
     var expr = operation.ToExpression();
     return Expression.Lambda(expr, Expression.Parameter(typeof(SPListItem), ReflectionHelper.CommonParameterName));
 }
Exemplo n.º 6
0
        private LambdaExpression translateArrayOperation(IReAnalyzer analyzer, string tag)
        {
            if (analyzer == null)
            {
                return null;
            }
            if (!analyzer.IsValid())
            {
                throw new IncorrectCamlException(tag);
            }
            var operation = analyzer.GetOperation();

            if (!(operation is ArrayOperation))
            {
                throw new CamlAnalysisException("ArrayOperation is expected");
            }

            int operandsCount = ((ArrayOperation) operation).OperandsCount;
            if (operandsCount == 0)
            {
                throw new CamlAnalysisException(
                    "ArrayOperation doesn't contain operands. There should be at least one operand");
            }

            var expr = operation.ToExpression();

            // this is important to specify the type of returning value explicitly in generic, becase otherwise
            // it will determine type by itself and it will be incorrect for ArrayOperation with orderings.
            // I.e. it will be Func<SPListItem, Camlex+Desc>, instead of Func<SPListItem,object>. In turn
            // it will cause exception in ReLinker, because parameter of type Func<SPListItem, Camlex+Desc>
            // can not be passed to the method OrderBy(Expression<Func<SPListItem, object>> expr);
            if (operandsCount == 1)
            {
                return Expression.Lambda<Func<SPListItem, object>>(expr,
                                                           Expression.Parameter(typeof (SPListItem),
                                                                                ReflectionHelper.CommonParameterName));
            }

            return Expression.Lambda<Func<SPListItem, object[]>>(expr,
                                                       Expression.Parameter(typeof(SPListItem),
                                                                            ReflectionHelper.CommonParameterName));
        }
Exemplo n.º 7
0
 private XElement getElement(IReAnalyzer analyzer)
 {
     return (analyzer == null ? null : analyzer.Element);
 }
Exemplo n.º 8
0
 private XElement getElement(IReAnalyzer analyzer)
 {
     return(analyzer == null ? null : analyzer.Element);
 }