public IState Next(Token token) { if (token.TokenType == TokenType.CloseTemplate) { _builder.AddOutputValue(new PropertyValueAccess { Name = _identifier }); return(new CloseTemplateState(_builder)); } if (token.TokenType == TokenType.Dot) { var valueAccess = new PropertyValueAccess { Name = _identifier }; return(new IdentifierDotState(valueAccess, _builder)); } if (token.TokenType == TokenType.LeftParenthesis) { return(new IdentifierLeftParenthesisState(_identifier, _builder)); } throw new ParsingException(this, token); }
public IState Next(Token token) { if (token.TokenType == TokenType.CloseTemplate) { _builder.AddOutputValue(_valueAccess); return(new CloseTemplateState(_builder)); } if (token.TokenType == TokenType.Dot) { return(new IdentifierDotState(_valueAccess, _builder)); } throw new ParsingException(this, token); }
public void AddOutputValueElement_GetResult_templateModel_contains_PropertyTemplateElement() { var property = new PropertyValueAccess { Name = "Count" }; _builder.AddOutputValue(property); TemplateModel templateModel = _builder.GetResult(); TemplateElement[] elements = templateModel.Elements.ToArray(); Assert.AreEqual(1, elements.Length); var element = (OutputValueTemplateElement)elements[0]; Assert.AreEqual("Count", element.ValueAccess.Name); }