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


C# ForeachStatement类代码示例

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


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

示例1: VisitForeachStatement

 public override void VisitForeachStatement(ForeachStatement foreachStatement)
 {
     base.VisitForeachStatement(foreachStatement);
     var rr = ctx.Resolve(foreachStatement) as ForEachResolveResult;
     if (rr == null)
         return;
     if (rr.ElementType.Kind == TypeKind.Unknown)
         return;
     if (ReflectionHelper.GetTypeCode(rr.ElementType) == TypeCode.Object)
         return;
     if (conversions == null) {
         conversions = CSharpConversions.Get(ctx.Compilation);
     }
     Conversion c = conversions.ImplicitConversion(rr.ElementType, rr.ElementVariable.Type);
     if (c.IsValid)
         return;
     var csResolver = ctx.GetResolverStateBefore(foreachStatement);
     var builder = new TypeSystemAstBuilder(csResolver);
     AstType elementType = builder.ConvertType(rr.ElementType);
     AstType variableType = foreachStatement.VariableType;
     string issueText = ctx.TranslateString("Collection element type '{0}' is not implicitly convertible to '{1}'");
     string fixText = ctx.TranslateString("Use type '{0}'");
     AddIssue(variableType, string.Format(issueText, elementType.GetText(), variableType.GetText()),
              new CodeAction(string.Format(fixText, elementType.GetText()),
                             script => script.Replace(variableType, elementType)));
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:26,代码来源:ExplicitConversionInForEachIssue.cs

示例2: VisitForeachStatement

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

示例3: VisitForeachStatement

			public override void VisitForeachStatement (ForeachStatement foreachStatement)
			{
				base.VisitForeachStatement (foreachStatement);

				if (HidesMember (ctx, foreachStatement, foreachStatement.VariableName))
					AddIssue (foreachStatement.VariableNameToken,
						ctx.TranslateString ("Local variable has the same name as a member and hides it"));
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:8,代码来源:LocalVariableHidesMemberIssue.cs

示例4: VisitForeachStatement

        public override void VisitForeachStatement(ForeachStatement foreachStatement)
        {
            var expression = string.Format("foreach ({0} {1} in {2})", foreachStatement.VariableType.GetText(), foreachStatement.VariableName, foreachStatement.InExpression.GetText());
            var token = CreateBlock(expression, SDNodeRole.ForEach);
            _tokenList.Add(token);

            VisitChildren(token.Statements, foreachStatement.EmbeddedStatement);
        }
开发者ID:JoeHosman,项目名称:sharpDox,代码行数:8,代码来源:MethodVisitor.cs

示例5: VisitForeachStatement

            public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
            {
                var invocationExpression = foreachStatement.InExpression as InvocationExpression;
                if(invocationExpression != null && invocationExpression.Target.ToString().EndsWith("Enum.GetValues"))
                {
                    UnlockWith(invocationExpression);
                }

                return base.VisitForeachStatement(foreachStatement, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:10,代码来源:ForEachWithEnumAchievement.cs

示例6: VisitForeachStatement

		public override void VisitForeachStatement(ForeachStatement foreachStatement) {
			bool oldIsInsideLoop = _isInsideLoop;
			try {
				_isInsideLoop = true;
				AddVariable(foreachStatement.VariableNameToken, foreachStatement.VariableName);
				base.VisitForeachStatement(foreachStatement);
			}
			finally {
				_isInsideLoop = oldIsInsideLoop;
			}
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:11,代码来源:VariableGatherer.cs

示例7: VisitForeachStatement

            public override void VisitForeachStatement(ForeachStatement foreachStatement)
            {
                base.VisitForeachStatement (foreachStatement);

                var resolveResult = ctx.Resolve (foreachStatement.VariableNameToken) as LocalResolveResult;
                if (resolveResult == null)
                    return;

                if (IsUsed (foreachStatement, resolveResult.Variable, foreachStatement.VariableNameToken))
                    return;

                AddIssue (foreachStatement.VariableNameToken, ctx.TranslateString ("Local variable is never used"));
            }
开发者ID:riviti,项目名称:NRefactory,代码行数:13,代码来源:LocalVariableNotUsedIssue.cs

示例8: VisitForeachStatement

 public virtual void VisitForeachStatement(ForeachStatement foreachStatement)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(foreachStatement);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs

示例9: VisitForeachStatement

 public abstract StringBuilder VisitForeachStatement(ForeachStatement foreachStatement, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs

示例10: ForeachStatement

        ForeachStatement ForeachStatement(IBlockNode Scope,IStatement Parent)
        {
            Step();

            var dbs = new ForeachStatement() {
                Location = t.Location,
                IsReverse = t.Kind == Foreach_Reverse,
                Parent = Parent
            };

            LastParsedObject = dbs;
            if(!Expect(OpenParenthesis))
                return dbs;

            var tl = new List<DVariable>();

            bool init=true;
            while(init || laKind == Comma)
            {
                if (init)
                    init = false;
                else
                    Step();

                var forEachVar = new DVariable{ Parent = Scope };
                forEachVar.Location = la.Location;

                if (laKind == Ref || laKind == InOut)
                {
                    Step();
                    if(forEachVar.Attributes == null)
                        forEachVar.Attributes = new List<DAttribute>();
                    forEachVar.Attributes.Add(new Modifier(t.Kind));
                }

                if(IsEOF){
                    TrackerVariables.ExpectingIdentifier = true;
                    SynErr(t.Kind,"Basic type or iteration variable identifier expected.");
                    return dbs;
                }

                LastParsedObject = forEachVar;

                if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Semicolon) || Lexer.CurrentPeekToken.Kind == Comma))
                {
                    Step();
                    forEachVar.NameLocation = t.Location;
                    forEachVar.Name = t.Value;
                }
                else
                {
                    var type = BasicType();

                    var tnode = Declarator(type, false, Scope);
                    if (tnode == null)
                        break;
                    if(forEachVar.Attributes != null)
                        if(tnode.Attributes == null)
                            tnode.Attributes = new List<DAttribute>(forEachVar.Attributes);
                        else
                            tnode.Attributes.AddRange(forEachVar.Attributes);
                    tnode.Location = forEachVar.Location;
                    forEachVar = (DVariable)tnode;
                }
                forEachVar.EndLocation = t.EndLocation;

                tl.Add(forEachVar);
            }

            dbs.ForeachTypeList = tl.ToArray();

            if(Expect(Semicolon))
                dbs.Aggregate = Expression(Scope);

            // ForeachRangeStatement
            if (laKind == DoubleDot)
            {
                Step();
                dbs.UpperAggregate = Expression();
            }

            if(Expect(CloseParenthesis))
                dbs.ScopedStatement = Statement(Scope: Scope, Parent: dbs);
            dbs.EndLocation = t.EndLocation;

            return dbs;
        }
开发者ID:EnergonV,项目名称:D_Parser,代码行数:87,代码来源:Parser_Impl.cs

示例11: VisitForeachStatement

		public override void VisitForeachStatement(ForeachStatement foreachStatement)
		{
			ForceSpacesBefore(foreachStatement.LParToken, policy.SpaceBeforeForeachParentheses);

			ForceSpacesAfter(foreachStatement.LParToken, policy.SpacesWithinForeachParentheses);
			ForceSpacesBefore(foreachStatement.RParToken, policy.SpacesWithinForeachParentheses);

			FixEmbeddedStatment(policy.StatementBraceStyle, policy.ForEachBraceForcement, foreachStatement.EmbeddedStatement);
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:9,代码来源:AstFormattingVisitor.cs

示例12: VisitForeachStatement

		public virtual void VisitForeachStatement (ForeachStatement foreachStatement)
		{
			VisitChildren (foreachStatement);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs

示例13: VisitForeachStatement

		public void VisitForeachStatement(ForeachStatement foreachStatement)
		{
			StartNode(foreachStatement);
			WriteKeyword(ForeachStatement.ForeachKeywordRole);
			Space(policy.SpaceBeforeForeachParentheses);
			LPar();
			Space(policy.SpacesWithinForeachParentheses);
			foreachStatement.VariableType.AcceptVisitor(this);
			Space();
			foreachStatement.VariableNameToken.AcceptVisitor(this);
			WriteKeyword(ForeachStatement.InKeywordRole);
			Space();
			foreachStatement.InExpression.AcceptVisitor(this);
			Space(policy.SpacesWithinForeachParentheses);
			RPar();
			WriteEmbeddedStatement(foreachStatement.EmbeddedStatement);
			EndNode(foreachStatement);
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:18,代码来源:CSharpOutputVisitor.cs

示例14: VisitForeachStatement

 public override void VisitForeachStatement(ForeachStatement foreachStatement)
 {
     if (findReturn)
     {
         base.VisitForeachStatement(foreachStatement);
     }
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:LambdaVisitor.cs

示例15: Visit

		public virtual void Visit(ForeachStatement s)
		{
			VisitChildren(s);

			if (s.ForeachTypeList != null)
				foreach (var t in s.ForeachTypeList)
					t.Accept(this);

			if (s.UpperAggregate != null)
				s.UpperAggregate.Accept(this);
			if (s.Aggregate != null)
				s.Aggregate.Accept(this);
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:13,代码来源:DefaultDepthFirstVisitor.cs


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