예제 #1
0
 public PredicateBuilder(Expression sourceExpression, ExpressionOperator @operator, object value, PredicateBuilderConfiguration configuration = null)
 {
     Configuration  = configuration ?? PredicateBuilderConfiguration.Default;
     Expression     = sourceExpression;
     Operator       = @operator;
     Value          = value;
     EffectiveType  = Nullable.GetUnderlyingType(Expression.Type) ?? Expression.Type;
     IsNullableType = EffectiveType != Expression.Type;
     IsNullable     = IsNullableType || !EffectiveType.IsValueType;
     DataType       = GetDataType(Expression.Type);
 }
예제 #2
0
        public ExpressionNodeVisitorInput(ParameterExpression itParameterExpression, PredicateBuilderConfiguration defaultConfiguration = null, IDictionary <string, PredicateBuilderConfiguration> configurations = null)
        {
            ItParameterExpression = itParameterExpression;
            DefaultConfiguration  = defaultConfiguration ?? PredicateBuilderConfiguration.Default;

            if (configurations != null)
            {
                Configurations = new ReadOnlyDictionary <string, PredicateBuilderConfiguration>(configurations);
            }
            else
            {
                Configurations = new Dictionary <string, PredicateBuilderConfiguration>();
            }
        }
예제 #3
0
        public Expression <Func <T, bool> > VisitLambda <T>(NodeBase root, PredicateBuilderConfiguration configuration = null)
        {
            var input = new ExpressionNodeVisitorInput(typeof(T), configuration);

            return(Expression.Lambda <Func <T, bool> >(Visit(root, input), input.ItParameterExpression));
        }
예제 #4
0
        public LambdaExpression VisitLambda(NodeBase root, Type instanceType, PredicateBuilderConfiguration configuration = null)
        {
            var input = new ExpressionNodeVisitorInput(instanceType, configuration);

            return(Expression.Lambda(Visit(root, input), input.ItParameterExpression));
        }
예제 #5
0
 protected virtual Expression BuildUnaryNodeExpression(BinaryNode node, ParameterExpression itParameter, PredicateBuilderConfiguration nodeConfiguration)
 {
     return(PredicateBuilder.GetPredicateExpression(itParameter, node.Expression, node.Operator, node.Value, nodeConfiguration));
 }
예제 #6
0
 public ExpressionNodeVisitorInput(Type itParameterType, string itParameterName, PredicateBuilderConfiguration defaultConfiguration, IDictionary <string, PredicateBuilderConfiguration> configurations = null)
     : this(Expression.Parameter(itParameterType, itParameterName ?? ""), defaultConfiguration, configurations)
 {
 }
예제 #7
0
 public ExpressionNodeVisitorInput(Type itParameterType, PredicateBuilderConfiguration defaultConfiguration, IDictionary <string, PredicateBuilderConfiguration> configurations)
     : this(itParameterType, defaultConfiguration?.ItParameterName, defaultConfiguration, configurations)
 {
 }
예제 #8
0
 public ExpressionNodeVisitorInput(Type itParameterType, PredicateBuilderConfiguration defaultConfiguration)
     : this(itParameterType, defaultConfiguration?.ItParameterName, defaultConfiguration, null)
 {
 }
예제 #9
0
        public static Expression GetPredicateExpression
            (Expression sourceExpression, ExpressionOperator @operator, object value, PredicateBuilderConfiguration configuration = null)
        {
            var predicateBuilder = new PredicateBuilder(sourceExpression, @operator, value, configuration);

            return(predicateBuilder.BuildPredicateExpression());
        }
예제 #10
0
        public static Expression GetPredicateExpression
            (ParameterExpression instanceParameter, string sourceExpression, ExpressionOperator @operator, object value, PredicateBuilderConfiguration configuration = null)
        {
            var left = MemberExpressionBuilder.GetExpressionSelector(instanceParameter, sourceExpression).Body;

            return(GetPredicateExpression(left, @operator, value, configuration));
        }
예제 #11
0
파일: NodeBase.cs 프로젝트: nsarris/Dynamix
 public Expression <Func <T, bool> > GetLambdaExpression <T>(PredicateBuilderConfiguration configuration = null)
 {
     return(new ExpressionNodeVisitor().VisitLambda <T>(this, configuration));
 }
예제 #12
0
파일: NodeBase.cs 프로젝트: nsarris/Dynamix
 public LambdaExpression GetLambdaExpression(Type type, PredicateBuilderConfiguration configuration = null)
 {
     return(new ExpressionNodeVisitor().VisitLambda(this, type, configuration));
 }