Exemplo n.º 1
0
        public override AstVisitAction VisitIndexExpression(IndexExpressionAst indexExpressionAst)
        {
            var targetValue = EvaluateAst(indexExpressionAst.Target);

            int index = (int)EvaluateAst(indexExpressionAst.Index);

            var stringTargetValue = targetValue as string;

            if (stringTargetValue != null)
            {
                var result = stringTargetValue[index];
                this._pipelineCommandRuntime.WriteObject(result);
            }

            else if (targetValue is IList)
            {
                var result = (targetValue as IList)[index];
                this._pipelineCommandRuntime.WriteObject(result);
            }

            else
            {
                throw new NotImplementedException(indexExpressionAst.ToString() + " " + targetValue.GetType());
            }

            return(AstVisitAction.SkipChildren);
        }
Exemplo n.º 2
0
 public override AstVisitAction VisitIndexExpression(IndexExpressionAst indexExpressionAst)
 {
     Console.WriteLine("Visited an IndexExpressionAst.");
     Console.WriteLine("    " + indexExpressionAst.ToString().Replace(Environment.NewLine, Environment.NewLine + "    "));
     return(AstVisitAction.Continue);
 }