Ejemplo n.º 1
0
        public virtual int ConvertTokens(IEnumerable <RPToken> tokens)
        {
            RPToken token = tokens.First();

            if (!_rpTokenTypeRPElementBuilderPairs.ContainsKey(token.TokenType))
            {
                throw new Exception($"{token.TokenType} does not have an associated RPElementBuilder");
            }

            Type rpElementBuilderType = _rpTokenTypeRPElementBuilderPairs[token.TokenType];

            if (rpElementBuilderType.GetMethod("ConvertTokens").DeclaringType == typeof(RPElementBuilder))
            {
                throw new Exception($"{rpElementBuilderType} does not implement the ConvertTokens method.");
            }

            IRPElementBuilder elementBuilder = (IRPElementBuilder)Activator.CreateInstance(rpElementBuilderType, new object[] { Options, Element });

            int tokensConsumed = elementBuilder.ConvertTokens(tokens);

            Element = elementBuilder.Element;

            return(tokensConsumed);
        }
Ejemplo n.º 2
0
 public RPTokenListReader(IRPElementBuilder elementBuilder)
 {
     _elementBuilder = elementBuilder;
 }