public virtual IRPResultNode EvaluateElement(IRPResultNode resultNode, IEnumerable <IRPElement> elements) { if (!elements.Any()) { return(resultNode); } IRPElement element = elements.First(); if (!_rpElementRPResultNodeBuilderPairs.ContainsKey(element.GetType())) { throw new Exception($"{element.GetType()} does not have an associated RPResultNodeBuilder"); } Type rpResultNodeBuilderType = _rpElementRPResultNodeBuilderPairs[element.GetType()]; if (rpResultNodeBuilderType.GetMethod("EvaluateElement").DeclaringType == typeof(RPResultNodeBuilder)) { throw new Exception($"{rpResultNodeBuilderType} does not implement the EvaluateElement method."); } IRPResultNodeBuilder resultNodeBuilder = (IRPResultNodeBuilder)Activator.CreateInstance(rpResultNodeBuilderType); return(resultNodeBuilder.EvaluateElement(resultNode, elements)); }
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); }
public void Clean() { Options = new Dictionary <string, string>(); Element = null; }
protected RPElementBuilder(Dictionary <string, string> options, IRPElement element) { Options = options; Element = element; }
public RPWildcardElementBuilder(Dictionary <string, string> options, IRPElement element) : base(options, element) { }
public RPGlobalRootElementBuilder(Dictionary <string, string> options, IRPElement element) : base(options, element) { }
public RPOpenBracketConsumer(Dictionary <string, string> options, IRPElement element) : base(options, element) { }
public RPSyntaxKindRegexPairElementBuilder(Dictionary <string, string> options, IRPElement element) : base(options, element) { }
public RPDeepConsumer(Dictionary <string, string> options, IRPElement element) : base(options, element) { }