public static Parse ( |
||
state | ||
blockStack | HandlebarsBlockStack | |
location | ||
expression | string | |
memberLocator | IMemberLocator | |
Результат |
public void Should_match_case_insensitivity_correctly(string expression, ExpressionNode expectedResult) { var scopes = CreateScopes(typeof(CaseTestModel)); var result = HandlebarsExpressionParser.Parse(scopes, expression); result.ShouldDeepEqual(expectedResult); }
public void Should_throw_if_expression_cant_be_parsed(string expression) { Assert.Throws <VeilParserException>(() => { HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), expression); }); }
public void Should_be_able_to_reference_parent_scopes_model() { var current = new { }; var parent = new { Name = "" }; var root = new { }; var scopes = CreateScopes(root.GetType(), parent.GetType(), current.GetType()); var result = HandlebarsExpressionParser.Parse(scopes, "../Name"); result.ShouldDeepEqual(Expression.Property(parent.GetType(), "Name", ExpressionScope.ModelOfParentScope)); }
public void Should_parse_field_from_subsubmodel() { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "SubModel.SubSubModel.SubSubField"); result.ShouldDeepEqual(Expression.SubModel( Expression.Property(typeof(Model), "SubModel"), Expression.SubModel( Expression.Field(typeof(SubModel), "SubSubModel"), Expression.Field(typeof(SubSubModel), "SubSubField")) ) ); }
public void Should_parse_as_late_bound_when_model_type_is_not_known <T>(T model) { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(T)), "Name"); result.ShouldDeepEqual(Expression.LateBound("Name", false, ExpressionScope.CurrentModelOnStack)); }
public void Should_parse_self_expression_node(string expression) { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(string)), expression); result.ShouldDeepEqual(Expression.Self(typeof(string))); }
public void Should_parse_function_from_submodel() { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Function()"); result.ShouldDeepEqual(Expression.Function(typeof(Model), "Function")); }
public void Should_parse_field() { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Field"); result.ShouldDeepEqual(Expression.Field(typeof(Model), "Field")); }
public void Should_parse_property() { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Property"); result.ShouldDeepEqual(Expression.Property(typeof(Model), "Property")); }
public void Should_parse_property_from_submodel() { var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "SubModel.SubProperty"); result.ShouldDeepEqual(SyntaxTreeExpression.SubModel(SyntaxTreeExpression.Property(typeof(Model), "SubModel"), SyntaxTreeExpression.Property(typeof(SubModel), "SubProperty"))); }
public ExpressionNode ParseExpression(string expression, SourceLocation location) { return(HandlebarsExpressionParser.Parse(this, BlockStack, location, expression, _memberLocator)); }
public ExpressionNode ParseExpression(string expression) { return(HandlebarsExpressionParser.Parse(BlockStack, expression)); }