Parse() 공개 정적인 메소드

public static Parse ( LinkedList scopes, string originalExpression ) : ExpressionNode
scopes LinkedList
originalExpression string
리턴 Veil.Parser.ExpressionNode
예제 #1
0
        public void Should_parse_hasitems_expression()
        {
            var model  = new { Items = new[] { 1, 2, 3 } };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "HasItems");

            result.ShouldDeepEqual(Expression.HasItems(Expression.Property(model.GetType(), "Items")));
        }
예제 #2
0
        public void Should_give_precedence_to_property_over_hasitems()
        {
            var model  = new { Items = new[] { 1, 2, 3 }, HasItems = true };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "HasItems");

            result.ShouldDeepEqual(Expression.Property(model.GetType(), "HasItems"));
        }
예제 #3
0
        public void Should_parse_current_keyword_as_self_expression()
        {
            var model  = new { };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Current");

            result.ShouldDeepEqual(Expression.Self(model.GetType()));
        }
예제 #4
0
        public void Should_parse_model_dot_property_as_proeprty_expression()
        {
            var model  = new { Name = "foo" };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Model.Name");

            result.ShouldDeepEqual(Expression.Property(model.GetType(), "Name", ExpressionScope.RootModel));
        }
예제 #5
0
        public void Should_preference_late_binding_over_Has_prefix()
        {
            var model  = new { HasItems = true, Items = new string[0] };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(typeof(object)), "Model.HasItems");

            result.ShouldDeepEqual(Expression.LateBound("HasItems", true, ExpressionScope.RootModel));
        }
예제 #6
0
        public void Should_parse_model_keywords_as_self_expression_scoped_to_root()
        {
            var model  = new { };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Model");

            result.ShouldDeepEqual(Expression.Self(model.GetType(), ExpressionScope.RootModel));
        }
예제 #7
0
        public void Should_throw_for_invalid_expressions(string expression)
        {
            var model = new { Name = "foo" };

            Assert.Throws <VeilParserException>(() =>
            {
                SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), expression);
            });
        }
예제 #8
0
        public void Should_parse_sub_model_expression_from_current_model()
        {
            var model  = new { User = new { Name = "Bob" } };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Current.User.Name");

            result.ShouldDeepEqual(Expression.SubModel(
                                       Expression.Property(model.GetType(), "User"),
                                       Expression.Property(model.User.GetType(), "Name")
                                       ));
        }
예제 #9
0
        public void Should_parse_sub_model_expression_from_root_model()
        {
            var model  = new { User = new { Name = "Bob" } };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Model.User.Name");

            result.ShouldDeepEqual(SyntaxTreeExpression.SubModel(
                                       SyntaxTreeExpression.Property(model.GetType(), "User", ExpressionScope.RootModel),
                                       SyntaxTreeExpression.Property(model.User.GetType(), "Name")
                                       ));
        }
예제 #10
0
        public void Should_parse_multiple_sub_model_expressions()
        {
            var model  = new { User = new { Department = new { Company = new { Name = "Foo" } } } };
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(model.GetType()), "Model.User.Department.Company.Name");

            result.ShouldDeepEqual(Expression.SubModel(
                                       Expression.Property(model.GetType(), "User", ExpressionScope.RootModel),
                                       Expression.SubModel(
                                           Expression.Property(model.User.GetType(), "Department"),
                                           Expression.SubModel(
                                               Expression.Property(model.User.Department.GetType(), "Company"),
                                               Expression.Property(model.User.Department.Company.GetType(), "Name")
                                               )
                                           )
                                       ));
        }
예제 #11
0
        public void Should_parse_as_late_bound_when_model_type_is_not_known <T>(T model)
        {
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(typeof(T)), "Model.Name");

            result.ShouldDeepEqual(Expression.LateBound("Name", true, ExpressionScope.RootModel));
        }
예제 #12
0
        public void Should_parse_field_references()
        {
            var result = SuperSimpleExpressionParser.Parse(CreateScopes(typeof(ViewModel)), "Model.FieldName");

            result.ShouldDeepEqual(Expression.Field(typeof(ViewModel), "FieldName", ExpressionScope.RootModel));
        }
예제 #13
0
 public ExpressionNode ParseExpression(string expression)
 {
     return(SuperSimpleExpressionParser.Parse(this.scopeStack, expression));
 }