protected internal Index(NRefactory.IndexerExpression indexerExpression, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { bool isAssignment = false; PropertyReference propertyReference = null; _indexerExpression = indexerExpression; isAssignment = IsAssignment(); Target = indexerExpression.Target.AcceptVisitor(Visitor, ParentScope); TryGetArguments(); if (indexerExpression.HasAnnotationOf<PropertyReference>(out propertyReference)) { var propertyInfo = Target.Type.GetProperty(propertyReference.Name); InternalType = propertyInfo.PropertyType; _indexer = propertyInfo; } else { _isArrayIndex = true; var targetType = Target.Type; if (targetType.HasElementType) { targetType = Target.Type.GetElementType(); } InternalType = targetType; _methodCall = _isAssignment ? Expression.ArrayAccess : (Func<Expression, IEnumerable<Expression>, Expression>)Expression.ArrayAccess; } }
protected internal Index(NRefactory.IndexerExpression indexerExpression, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { bool isAssignment = false; PropertyReference propertyReference = null; _indexerExpression = indexerExpression; isAssignment = IsAssignment(); Target = indexerExpression.Target.AcceptVisitor(Visitor, ParentScope); TryGetArguments(); if (indexerExpression.HasAnnotationOf <PropertyReference>(out propertyReference)) { var propertyInfo = Target.Type.GetProperty(propertyReference.Name); InternalType = propertyInfo.PropertyType; _indexer = propertyInfo; } else { _isArrayIndex = true; var targetType = Target.Type; if (targetType.HasElementType) { targetType = Target.Type.GetElementType(); } InternalType = targetType; _methodCall = _isAssignment ? Expression.ArrayAccess : (Func <Expression, IEnumerable <Expression>, Expression>)Expression.ArrayAccess; } }
private object EvaluateIndexerExpression(ICSharpCode.NRefactory.CSharp.IndexerExpression indexerExpression, CodeContext codeContext) { object evaluatedTarget = EvaluateExpression(indexerExpression.Target, codeContext); if (evaluatedTarget is RuntimeCsvRepresentation) { List <object> evaluatedArguments = new List <object>(); foreach (var argument in indexerExpression.Arguments) { evaluatedArguments.Add(EvaluateExpression(argument, codeContext)); } string requiredKey = evaluatedArguments[0] as string; RuntimeCsvRepresentation rcr = evaluatedTarget as RuntimeCsvRepresentation; return(GetCsvEntryByRequiredKey(requiredKey, rcr)); } return(null); }
public static Index Index(NRefactory.IndexerExpression indexerExpression, IScope scope, INRefcatoryExpressionVisitor visitor) { return(new Index(indexerExpression, scope, visitor)); }
void IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression) { Visit(EnterIndexerExpression, LeaveIndexerExpression, indexerExpression); }
public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data) { ParenthesizeIfRequired(indexerExpression.Target, Primary); return(base.VisitIndexerExpression(indexerExpression, data)); }
public virtual S VisitIndexerExpression(IndexerExpression indexerExpression, T data) { return(VisitChildren(indexerExpression, data)); }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { IndexerExpression o = other as IndexerExpression; return(o != null && this.Target.DoMatch(o.Target, match) && this.Arguments.DoMatch(o.Arguments, match)); }
public virtual S VisitIndexerExpression(IndexerExpression indexerExpression, T data) { throw new NotImplementedException(); }
public override AstExpression VisitIndexerExpression(NRefactory.IndexerExpression indexerExpression, IScope scope) { return(AstExpression.Index(indexerExpression, scope, this)); }