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


C# Ast.ForeachStatement类代码示例

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


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

示例1: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			if (nameComparer.Equals(from, foreachStatement.VariableName)) {
				foreachStatement.VariableName = to;
			}
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:7,代码来源:RenameIdentifierVisitor.cs

示例2: VisitForeachStatement

            public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
            {
                //Looks convoluted solution not sure this is correct way to detect something of form (foreach(var t in Enum.GetValue/GetNames(...))
                InvocationExpression expr = foreachStatement.Expression as InvocationExpression;

                if (expr != null)
                {
                    MemberReferenceExpression expr2 = expr.TargetObject as MemberReferenceExpression;
                    if (expr2 != null)
                    {
                        IdentifierExpression expr3 = expr2.TargetObject as IdentifierExpression;
                        if (expr3 != null && expr3.Identifier == "Enum")
                        {
                            UnlockWith(foreachStatement);
                        }
                    }
                }
                return base.VisitForeachStatement(foreachStatement, data);
            }
开发者ID:timdams,项目名称:strokes,代码行数:19,代码来源:ForEachWithEnumAchievement.cs

示例3: VisitForeachStatement

 public override object VisitForeachStatement (ForeachStatement node, object data)
 {
     if (node.EmbeddedStatement is EmptyStatement)
         return null;
     
     var iteratorName = GetNextIteratorName ();
     
     Write ("var ", iteratorName, " = ");
     var extType = node.Expression.AcceptVisitor (this, null);
     
     var ctype = extType as Mono.Cecil.TypeReference;
     var itype = extType as ICSharpCode.NRefactory.Ast.TypeReference;
     
     var isArray = false;
     
     if (ctype != null) {
         isArray = ctype.FullName.IndexOf ("[]") > 0;
     } else if (itype != null) {
         isArray = itype.IsArrayType;
     }
     
     //Console.WriteLine ("Node: {0}", name);
     if (isArray) {
         var iName = GetNextIteratorName();
         Write (";");
         NewLine ();
         Write ("for(var ",iName,"=0;", iName, " < ", iteratorName, ".length;", iName, "++)");
         
         NewLine ();
         BeginBlock ();
         PushLocals ();
         Write ("var ", node.VariableName, "=", iteratorName, "[", iName, "];");
         NewLine ();
         Locals.Add (node.VariableName, node.TypeReference);
         
         BlockStatement block = node.EmbeddedStatement as BlockStatement;
         if (block != null) {
             block.AcceptChildren (this, null);
         } else {
             node.EmbeddedStatement.AcceptVisitor (this, null);
         }
         PopLocals ();
         EndBlock ();
         NewLine ();
     } else {
         Write (".", CREATE_ITERATOR_NAME, "();");
         
         NewLine ();
         
         Write ("while(", iteratorName, ".", ITERATOR_HAS_NEXT_NAME, "()", ") ");
         BeginBlock ();
         
         Write ("var ", node.VariableName, " = ", iteratorName, ".", ITERATOR_NEXT_NAME, ";");
         NewLine ();
         
         PushLocals ();
         Locals.Add (node.VariableName, node.TypeReference);
         
         BlockStatement block = node.EmbeddedStatement as BlockStatement;
         if (block != null) {
             block.AcceptChildren (this, null);
         } else {
             node.EmbeddedStatement.AcceptVisitor (this, null);
         }
         
         PopLocals ();
         
         EndBlock ();
         NewLine ();
     }
     return null;
 }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:72,代码来源:JsEmitter.cs

示例4: TrackedVisitForeachStatement

 public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     this.AppendIndented(string.Empty);
     this.CreateInitStatement(foreachStatement);
     this.AppendLine();
     this.AppendIndentedLine("while enumerator.MoveNext():");
     this.IncreaseIndent();
     this.AppendIndentedLine(string.Concat(foreachStatement.VariableName, " = enumerator.Current"));
     foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
     this.DecreaseIndent();
     return null;
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:12,代码来源:NRefactoryToPythonConverter.cs

示例5: AppendForeachVariableName

 private void AppendForeachVariableName(ForeachStatement foreachStatement)
 {
     IdentifierExpression expression = foreachStatement.Expression as IdentifierExpression;
     InvocationExpression invocationExpression = foreachStatement.Expression as InvocationExpression;
     MemberReferenceExpression memberReferenceExpression = foreachStatement.Expression as MemberReferenceExpression;
     if (expression != null)
     {
         this.Append(expression.Identifier);
     }
     else if (invocationExpression != null)
     {
         invocationExpression.AcceptVisitor(this, null);
     }
     else if (memberReferenceExpression != null)
     {
         memberReferenceExpression.AcceptVisitor(this, null);
     }
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:18,代码来源:NRefactoryToPythonConverter.cs

示例6: TrackedVisitForeachStatement

		public virtual object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data) {
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs

示例7: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			if (!foreachStatement.EmbeddedStatement.IsNull) {
				AddVariable(foreachStatement.TypeReference,
				            foreachStatement.VariableName,
				            foreachStatement.EmbeddedStatement.StartLocation,
				            foreachStatement.EndLocation,
				            false, true,
				            foreachStatement.Expression,
				            null,
				            false,
				            foreachStatement.EmbeddedStatement.StartLocation);
			}
			
			if (foreachStatement.Expression != null) {
				foreachStatement.Expression.AcceptVisitor(this, data);
			}
			if (foreachStatement.EmbeddedStatement == null) {
				return data;
			}
			return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:22,代码来源:LookupTableVisitor.cs

示例8: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			base.VisitForeachStatement(foreachStatement, data);
			
			if (resolver.CompilationUnit == null)
				return null;
			
			if (foreachStatement.TypeReference.IsNull) {
				ResolveResult rr = resolver.ResolveIdentifier(foreachStatement.VariableName, foreachStatement.StartLocation, ExpressionContext.Default);
				if (rr != null && rr.ResolvedType != null) {
					BlockStatement blockStatement = foreachStatement.EmbeddedStatement as BlockStatement;
					if (blockStatement == null) {
						blockStatement = new BlockStatement();
						blockStatement.AddChild(foreachStatement.EmbeddedStatement);
						foreachStatement.EmbeddedStatement = blockStatement;
					}
					
					string newVariableName = foreachStatement.VariableName + "_loopVariable";
					
					ExpressionStatement st = new ExpressionStatement(
						new AssignmentExpression(
							new IdentifierExpression(foreachStatement.VariableName),
							AssignmentOperatorType.Assign,
							new IdentifierExpression(newVariableName)));
					blockStatement.Children.Insert(0, st);
					st.Parent = blockStatement;
					
					foreachStatement.VariableName = newVariableName;
					foreachStatement.TypeReference = ConvertType(rr.ResolvedType);
				}
			}
			return null;
		}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:33,代码来源:VBNetToCSharpConvertVisitor.cs

示例9: VisitStatement

			public void VisitStatement (ForeachStatement statement, MethodProperties meth)
			{
				meth.CyclometricComplexity++;
				VisitExpression(((ForeachStatement)(statement)).Expression, meth);
				
				VisitExpression(statement.NextExpression, meth);						
				
				foreach(var innerStatement in ((ForeachStatement)statement).EmbeddedStatement.Children)
					VisitStatement((Statement)innerStatement, meth);
			}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:ASTVisitor.cs

示例10: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			return base.VisitForeachStatement(foreachStatement, true);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:FindJumpInstructionsVisitor.cs

示例11: VisitForeachStatement

 public virtual bool VisitForeachStatement(ForeachStatement foreachStatement, object d)
 {
     if ((foreachStatement == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((foreachStatement.TypeReference == null)) {
         return SetFailure();
     }
     if ((foreachStatement.Expression == null)) {
         return SetFailure();
     }
     if ((foreachStatement.NextExpression == null)) {
         return SetFailure();
     }
     if ((foreachStatement.EmbeddedStatement == null)) {
         return SetFailure();
     }
     if(foreachStatement.GetType() != d.GetType()) {return SetFailure();}
     var data = (ForeachStatement)d;
     if (!IsMatch(foreachStatement, data)) {
         return SetFailure();
     }
     foreachStatement.TypeReference.AcceptVisitor(this, data.TypeReference);
     foreachStatement.Expression.AcceptVisitor(this, data.Expression);
     foreachStatement.NextExpression.AcceptVisitor(this, data.NextExpression);
     return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data.EmbeddedStatement);
 }
开发者ID:jbuedel,项目名称:AgentRalphPlugin,代码行数:30,代码来源:AstComparisonVisitor.Generated.cs

示例12: IsMatch

 private bool IsMatch(ForeachStatement left, ForeachStatement right)
 {
     return left.VariableName == right.VariableName;
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:4,代码来源:AstComparisonVisitor.cs

示例13: VisitForeachStatement

 public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     foreachStatement.Expression.Parent = foreachStatement;
     foreachStatement.TypeReference.Parent = foreachStatement;
     return base.VisitForeachStatement(foreachStatement, data);
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:6,代码来源:ParentVisitor.cs

示例14: VisitForeachStatement

		public object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			B.ForStatement fs = new B.ForStatement(GetLexicalInfo(foreachStatement));
			fs.EndSourceLocation = GetLocation(foreachStatement.EndLocation);
			fs.Iterator = ConvertExpression(foreachStatement.Expression);
			fs.Declarations.Add(new B.Declaration(foreachStatement.VariableName, ConvertTypeReference(foreachStatement.TypeReference)));
			fs.Block = ConvertBlock(foreachStatement.EmbeddedStatement);
			return fs;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:ConvertVisitorStatements.cs

示例15: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			curBlock.Add(foreachStatement.VariableName);
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:5,代码来源:PrefixFieldsVisitor.cs


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