Пример #1
0
        public static Expression <Func <T, P1, U> > ParseToExpression <T, P1, U>(String expression)
        {
            StringAdvancedTokenizer tokenizer = new StringAdvancedTokenizer(opchecker);
            ExpressionConverterExt <String, String, String> converter =
                new ExpressionConverterExt <String, String, String>(
                    opchecker, tokenizer, tokenConverter);
            IList <String> postfix = converter.InfixToPostfix(expression);
            PostfixExpressionToLambda <T> executor = new PostfixExpressionToLambda <T>();

            return(executor.Execute <P1, U>(postfix));
        }
        private Constraint GetConstraint()
        {
            ExpressionConverterExt <List <Constraint>, Constraint, Constraint> converter =
                new ExpressionConverterExt <List <Constraint>, Constraint, Constraint>(
                    new ConstraintOperatorChecker(), new DummyTokenizer(), new DummyTokenConverter());
            PostfixConstraintExecutor executor = new PostfixConstraintExecutor();
            List <Constraint>         list     = new List <Constraint>();

            list.AddRange(constraints);
            list.Reverse();
            IList <Constraint> postfix = converter.InfixToPostfix(list);

            return(executor.ResolveExpression(postfix));
        }
Пример #3
0
        public bool Validate(object subject)
        {
            ExpressionConverterExt <List <IConstraint>, IConstraint, IConstraint> converter =
                new ExpressionConverterExt <List <IConstraint>, IConstraint, IConstraint>(
                    new ConstraintOperatorChecker(), new DummyTokenizer(), new DummyTokenConverter());
            PostfixIConstraintExecutor executor = new PostfixIConstraintExecutor();
            List <IConstraint>         list     = new List <IConstraint>();

            list.AddRange(constraints);
            list.Reverse();
            IList <IConstraint> postfix        = converter.InfixToPostfix(list);
            IConstraint         lastConstraint = executor.ResolveExpression(postfix);

            return(lastConstraint.Validate(subject));
        }
 public bool Validate(object subject)
 {
     ExpressionConverterExt<List<IConstraint>, IConstraint, IConstraint> converter =
     new ExpressionConverterExt<List<IConstraint>, IConstraint, IConstraint>(
         new ConstraintOperatorChecker(), new DummyTokenizer(), new DummyTokenConverter());
     PostfixIConstraintExecutor executor = new PostfixIConstraintExecutor();
     List<IConstraint> list = new List<IConstraint>();
     list.AddRange(constraints);
     list.Reverse();
     IList<IConstraint> postfix = converter.InfixToPostfix(list);
     IConstraint lastConstraint = executor.ResolveExpression(postfix);
     return lastConstraint.Validate(subject);
 }