当前位置: 首页>>代码示例>>C#>>正文


C# Ast.IndexerExpression类代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.Ast.IndexerExpression的典型用法代码示例。如果您正苦于以下问题:C# IndexerExpression类的具体用法?C# IndexerExpression怎么用?C# IndexerExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexerExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了IndexerExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitIndexerExpression

 public override object VisitIndexerExpression(IndexerExpression indexer, object data)
 {
     if (GetPrecedence(indexer.TargetObject) >= GetPrecedence(indexer)) {
         indexer.TargetObject = Deparenthesize(indexer.TargetObject);
     }
     return base.VisitIndexerExpression(indexer, data);
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:7,代码来源:RemoveParenthesis.cs

示例2: VisitIndexerExpression

		public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
		{
			List<int> indexes = new List<int>();
			foreach(Expression indexExpr in indexerExpression.Indexes) {
				Value indexValue = (Value)indexExpr.AcceptVisitor(this, null);
				if (!indexValue.Type.IsInteger) throw new GetValueException("Integer expected");
				indexes.Add((int)indexValue.PrimitiveValue);
			}
			Value target = (Value)indexerExpression.TargetObject.AcceptVisitor(this, null);
			if (!target.Type.IsArray) throw new GetValueException("Target is not array");
			return target.GetArrayElement(indexes.ToArray());
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:12,代码来源:EvaluateAstVisitor.cs

示例3: VisitMemberReferenceExpression

        public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
        {
            var identifierExpression = memberReferenceExpression.TargetObject as IdentifierExpression;
            if (identifierExpression == null || identifierExpression.Identifier != identifier)
                return base.VisitMemberReferenceExpression(memberReferenceExpression, data);

            var indexerExpression = new IndexerExpression(
                memberReferenceExpression.TargetObject,
                new List<Expression> { new PrimitiveExpression(memberReferenceExpression.MemberName, memberReferenceExpression.MemberName) });

            ReplaceCurrentNode(indexerExpression);
            indexerExpression.Parent = memberReferenceExpression.Parent;

            return indexerExpression;
        }
开发者ID:sirrocco,项目名称:rhino-divandb,代码行数:15,代码来源:TransformVisitor.cs

示例4: TransformMapDefinition

        private VariableDeclaration TransformMapDefinition()
        {
            var variableDeclaration = QueryParsingUtils.GetVariableDeclaration(indexDefinition.Map);
            var queryExpression = ((QueryExpression) variableDeclaration.Initializer);
            var expression = queryExpression.FromClause.InExpression;
            if(expression is MemberReferenceExpression) // collection
            {
                var mre = (MemberReferenceExpression)expression;
                queryExpression.FromClause.InExpression = mre.TargetObject;
                //doc["@metadata"]["Raven-Entity-Name"]
                var metadata = new IndexerExpression(
                    new IndexerExpression(new IdentifierExpression(queryExpression.FromClause.Identifier), new List<Expression> { new PrimitiveExpression("@metadata", "@metadata") }),
                    new List<Expression> { new PrimitiveExpression("Raven-Entity-Name", "Raven-Entity-Name") }
                    );
                queryExpression.MiddleClauses.Insert(0,
                    new QueryExpressionWhereClause
                    {
                        Condition =
                            new BinaryOperatorExpression(
                                metadata,
                                BinaryOperatorType.Equality,
                                new PrimitiveExpression(mre.MemberName, mre.MemberName)
                                )
                    });
            }
            var selectOrGroupClause = queryExpression.SelectOrGroupClause;
            var projection = ((QueryExpressionSelectClause) selectOrGroupClause).Projection;
            var objectInitializer = ((ObjectCreateExpression) projection).ObjectInitializer;

            var identifierExpression = new IdentifierExpression(queryExpression.FromClause.Identifier);
            objectInitializer.CreateExpressions.Add(
                new NamedArgumentExpression
                {
                    Name = "__document_id",
                    Expression = new MemberReferenceExpression(identifierExpression, "__document_id")
                });
            return variableDeclaration;
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:38,代码来源:DynamicViewCompiler.cs

示例5: VisitIndexerExpression

		public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
		{
			IReturnType target = ResolveType(indexerExpression.TargetObject);
			return CreateMemberResolveResult(
				GetIndexer(target, indexerExpression.Indexes)
			);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:ResolveVisitor.cs

示例6: TransformMapDefinitionFromLinqQuerySyntax

		private VariableDeclaration TransformMapDefinitionFromLinqQuerySyntax(string query, out string entityName)
		{
			entityName = null;
			var variableDeclaration = QueryParsingUtils.GetVariableDeclarationForLinqQuery(query, RequiresSelectNewAnonymousType);
			var queryExpression = ((QueryExpression) variableDeclaration.Initializer);
			var expression = queryExpression.FromClause.InExpression;
			if(expression is MemberReferenceExpression) // collection
			{
				var mre = (MemberReferenceExpression)expression;
				entityName = mre.MemberName;
				queryExpression.FromClause.InExpression = mre.TargetObject;
				//doc["@metadata"]["Raven-Entity-Name"]
				var metadata = new IndexerExpression(
					new IndexerExpression(new IdentifierExpression(queryExpression.FromClause.Identifier), new List<Expression> { new PrimitiveExpression("@metadata", "@metadata") }),
					new List<Expression> { new PrimitiveExpression(Constants.RavenEntityName, Constants.RavenEntityName) }
					);
				queryExpression.MiddleClauses.Insert(0, 
				                                     new QueryExpressionWhereClause
				                                     {
				                                     	Condition = 
				                                     		new BinaryOperatorExpression(
				                                     		metadata,
				                                     		BinaryOperatorType.Equality,
				                                     		new PrimitiveExpression(mre.MemberName, mre.MemberName)
				                                     		)
				                                     });
			}
			var selectOrGroupClause = queryExpression.SelectOrGroupClause;
			var projection = ((QueryExpressionSelectClause) selectOrGroupClause).Projection;
			if(projection is ObjectCreateExpression == false)
				return variableDeclaration;

			var objectInitializer = ((ObjectCreateExpression) projection).ObjectInitializer;

			var identifierExpression = new IdentifierExpression(queryExpression.FromClause.Identifier);

			if (objectInitializer.CreateExpressions.OfType<NamedArgumentExpression>().Any(x => x.Name == Constants.DocumentIdFieldName))
				return variableDeclaration;

			objectInitializer.CreateExpressions.Add(
				new NamedArgumentExpression
				{
					Name = Constants.DocumentIdFieldName,
					Expression = new MemberReferenceExpression(identifierExpression, Constants.DocumentIdFieldName)
				});
			return variableDeclaration;
		}
开发者ID:neiz,项目名称:ravendb,代码行数:47,代码来源:DynamicViewCompiler.cs

示例7: AddEntityNameFilteringIfNeeded

        private void AddEntityNameFilteringIfNeeded(VariableDeclaration variableDeclaration, out string entityName)
        {
            entityName = null;
            var invocationExpression = ((InvocationExpression)variableDeclaration.Initializer);
            var targetExpression = ((MemberReferenceExpression)invocationExpression.TargetObject);
            while (targetExpression.TargetObject is InvocationExpression)
            {
                invocationExpression = (InvocationExpression) targetExpression.TargetObject;
                targetExpression = (MemberReferenceExpression)invocationExpression.TargetObject;
            }
            if (targetExpression.TargetObject is MemberReferenceExpression) // collection
            {
                var mre = (MemberReferenceExpression)targetExpression.TargetObject;
                entityName = mre.MemberName;
                //doc["@metadata"]["Raven-Entity-Name"]
                var metadata = new IndexerExpression(
                    new IndexerExpression(new IdentifierExpression("__document"), new List<Expression> { new PrimitiveExpression("@metadata", "@metadata") }),
                    new List<Expression> { new PrimitiveExpression("Raven-Entity-Name", "Raven-Entity-Name") }
                    );
                var whereMethod = new InvocationExpression(new MemberReferenceExpression(mre.TargetObject, "Where"),
                                                           new List<Expression>
                                                           {
                                                           	new LambdaExpression
                                                           	{
                                                           		Parameters =
                                                           			{
                                                           				new ParameterDeclarationExpression(null, "__document")
                                                           			},
                                                           		ExpressionBody = new BinaryOperatorExpression(
                                                           			metadata,
                                                           			BinaryOperatorType.Equality,
                                                           			new PrimitiveExpression(mre.MemberName, mre.MemberName)
                                                           			)
                                                           	}
                                                           });

                invocationExpression.TargetObject = new MemberReferenceExpression(whereMethod, targetExpression.MemberName);

            }
        }
开发者ID:vinone,项目名称:ravendb,代码行数:40,代码来源:DynamicViewCompiler.cs

示例8: GetIndexer

		public IProperty GetIndexer(IndexerExpression indexerExpression)
		{
			IReturnType type = (IReturnType)indexerExpression.TargetObject.AcceptVisitor(this, null);
			if (type == null) {
				return null;
			}
			List<IProperty> indexers = type.GetProperties();
			// remove non-indexers:
			for (int i = 0; i < indexers.Count; i++) {
				if (!indexers[i].IsIndexer)
					indexers.RemoveAt(i--);
			}
			IReturnType[] parameters = new IReturnType[indexerExpression.Indexes.Count];
			for (int i = 0; i < parameters.Length; i++) {
				Expression expr = indexerExpression.Indexes[i] as Expression;
				if (expr != null)
					parameters[i] = (IReturnType)expr.AcceptVisitor(this, null);
			}
			return MemberLookupHelper.FindOverload(indexers.ToArray(), parameters);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:TypeVisitor.cs

示例9: TrackedVisitIndexerExpression

		public override object TrackedVisitIndexerExpression(IndexerExpression indexerExpression, object data)
		{
			indexerExpression.TargetObject.AcceptVisitor(this, data);

			// Add indices.
			foreach (Expression expression in indexerExpression.Indexes) {
				Append("[");
				expression.AcceptVisitor(this, data);
				Append("]");
			}

			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:13,代码来源:NRefactoryToPythonConverter.cs

示例10: VisitIndexerExpression

		public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
		{
			IProperty i = GetIndexer(indexerExpression);
			if (i != null)
				return i.ReturnType;
			else
				return null;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:TypeVisitor.cs

示例11: VisitIndexerExpression

		public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
		{
			return base.VisitIndexerExpression(indexerExpression, data);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:4,代码来源:NRefactoryAstVisitor.cs

示例12: VisitIndexerExpression

 public virtual object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
 {
     Debug.Assert((indexerExpression != null));
     Debug.Assert((indexerExpression.TargetObject != null));
     Debug.Assert((indexerExpression.Indexes != null));
     indexerExpression.TargetObject.AcceptVisitor(this, data);
     foreach (Expression o in indexerExpression.Indexes) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     return null;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:AbstractASTVisitor.cs

示例13: PrimaryExpr


//.........这里部分代码省略.........
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(35)) {

#line  1997 "cs.ATG" 
			startLocation = la.Location; 
			switch (la.kind) {
			case 31: {
				lexer.NextToken();

#line  1999 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				break;
			}
			case 32: {
				lexer.NextToken();

#line  2001 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				break;
			}
			case 47: {
				PointerMemberAccess(
#line  2003 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 15: {
				MemberAccess(
#line  2004 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 20: {
				lexer.NextToken();

#line  2008 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  2009 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(25)) {
					Argument(
#line  2010 "cs.ATG" 
out expr);

#line  2010 "cs.ATG" 
					SafeAdd(pexpr, parameters, expr); 
					while (la.kind == 14) {
						lexer.NextToken();
						Argument(
#line  2011 "cs.ATG" 
out expr);

#line  2011 "cs.ATG" 
						SafeAdd(pexpr, parameters, expr); 
					}
				}
				Expect(21);
				break;
			}
			case 18: {

#line  2017 "cs.ATG" 
				List<Expression> indices = new List<Expression>();
				pexpr = new IndexerExpression(pexpr, indices);
				
				lexer.NextToken();
				Expr(
#line  2020 "cs.ATG" 
out expr);

#line  2020 "cs.ATG" 
				SafeAdd(pexpr, indices, expr); 
				while (la.kind == 14) {
					lexer.NextToken();
					Expr(
#line  2021 "cs.ATG" 
out expr);

#line  2021 "cs.ATG" 
					SafeAdd(pexpr, indices, expr); 
				}
				Expect(19);
				break;
			}
			}

#line  2024 "cs.ATG" 
			if (pexpr != null) {
			if (pexpr.StartLocation.IsEmpty)
				pexpr.StartLocation = startLocation;
			if (pexpr.EndLocation.IsEmpty)
				pexpr.EndLocation = t.EndLocation;
			}
			
		}
	}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:101,代码来源:Parser.cs

示例14: AddEntityNameFilteringIfNeeded

		private void AddEntityNameFilteringIfNeeded(VariableDeclaration variableDeclaration, out string entityName)
		{
			entityName = null;
			var invocationExpression = ((InvocationExpression)variableDeclaration.Initializer);
			var targetExpression = ((MemberReferenceExpression)invocationExpression.TargetObject);
			while (targetExpression.TargetObject is InvocationExpression)
			{
				invocationExpression = (InvocationExpression) targetExpression.TargetObject;
				targetExpression = (MemberReferenceExpression)invocationExpression.TargetObject;
			}
			if (targetExpression.TargetObject is MemberReferenceExpression) // collection
			{
				var mre = (MemberReferenceExpression)targetExpression.TargetObject;
				entityName = mre.MemberName;
				//doc["@metadata"]["Raven-Entity-Name"]
				var metadata = new IndexerExpression(
					new IndexerExpression(new IdentifierExpression("__document"), new List<Expression> { new PrimitiveExpression("@metadata", "@metadata") }),
					new List<Expression> { new PrimitiveExpression(Constants.RavenEntityName, Constants.RavenEntityName) }
					);

				// string.Equals(doc["@metadata"]["Raven-Entity-Name"], "Blogs", StringComparison.InvariantCultureIgnoreCase)
				var binaryOperatorExpression =
					new InvocationExpression(
						new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference("string", true)), "Equals"),
						new List<Expression>
						{
							metadata,
							new PrimitiveExpression(mre.MemberName, mre.MemberName),
							new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference(typeof(StringComparison).FullName)),"InvariantCultureIgnoreCase")
						});
				var whereMethod = new InvocationExpression(new MemberReferenceExpression(mre.TargetObject, "Where"),
				                                           new List<Expression>
				                                           {
				                                           	new LambdaExpression
				                                           	{
				                                           		Parameters =
				                                           			{
				                                           				new ParameterDeclarationExpression(null, "__document")
				                                           			},
				                                           		ExpressionBody = binaryOperatorExpression
				                                           	}
				                                           });

				invocationExpression.TargetObject = new MemberReferenceExpression(whereMethod, targetExpression.MemberName);

			}
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:47,代码来源:DynamicViewCompiler.cs

示例15: VisitIndexerExpression

 public object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
 {
     throw new NotImplementedException ();
 }
开发者ID:Monobjc,项目名称:monobjc-tools,代码行数:4,代码来源:CodeDomExpressionPrinter.cs


注:本文中的ICSharpCode.NRefactory.Ast.IndexerExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。