// ExpressionNode : '#{' Identifier ('[' Index ']')? '}' private ExpressionNode ParseExpressionNode(ref int index) { // the previous string node either ended because it reached the end or because the start // of an expression was encoutered, so we can safely consume two characters index += 2; if (index >= _configuration.Length) { return(null); } ExpressionNode result = ParseIdentifier(ref index); if (_configuration[index] == '[') { index++; result = new IndexAccessorNode((IdentifierNode)result, ParseIndex(ref index)); ParseChar(']', ref index); } ParseChar('}', ref index); return(result); }
private IDependencyResolverPolicy DoGetResolverPolicy(IndexAccessorNode node) { var identifier = node.Children[0] as IdentifierNode; var index = node.Children[1] as StringNode; if (identifier == null || index == null) { throw new InvalidOperationException("Index accessor node should have an identifier and an index."); } if (identifier.Identifier == "stepExecutionContext") { return(new StepContextDependencyResolverPolicy <T>(index.Literal)); } if (identifier.Identifier == "jobExecutionContext") { return(new JobContextDependencyResolverPolicy <T>(index.Literal)); } if (identifier.Identifier == "settings") { return(new SettingsDependencyResolverPolicy <T>(index.Literal)); } throw new InvalidOperationException(string.Format("Unsupported identifier at {0}: {1}.", node.Position.Start, identifier.Identifier)); }
// ExpressionNode : '#{' Identifier ('[' Index ']')? '}' private ExpressionNode ParseExpressionNode(ref int index) { // the previous string node either ended because it reached the end or because the start // of an expression was encoutered, so we can safely consume two characters index += 2; if (index >= _configuration.Length) { return null; } ExpressionNode result = ParseIdentifier(ref index); if (_configuration[index] == '[') { index++; result = new IndexAccessorNode((IdentifierNode)result, ParseIndex(ref index)); ParseChar(']', ref index); } ParseChar('}', ref index); return result; }