コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static Index Index(NRefactory.IndexerExpression indexerExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
 {
     return(new Index(indexerExpression, scope, visitor));
 }
コード例 #5
0
 void IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression)
 {
     Visit(EnterIndexerExpression, LeaveIndexerExpression, indexerExpression);
 }
コード例 #6
0
 public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
 {
     ParenthesizeIfRequired(indexerExpression.Target, Primary);
     return(base.VisitIndexerExpression(indexerExpression, data));
 }
コード例 #7
0
 public virtual S VisitIndexerExpression(IndexerExpression indexerExpression, T data)
 {
     return(VisitChildren(indexerExpression, data));
 }
コード例 #8
0
        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));
        }
コード例 #9
0
 public virtual S VisitIndexerExpression(IndexerExpression indexerExpression, T data)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 public override AstExpression VisitIndexerExpression(NRefactory.IndexerExpression indexerExpression, IScope scope)
 {
     return(AstExpression.Index(indexerExpression, scope, this));
 }