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


C# IfElseStatement.AddChild方法代码示例

本文整理汇总了C#中IfElseStatement.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# IfElseStatement.AddChild方法的具体用法?C# IfElseStatement.AddChild怎么用?C# IfElseStatement.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IfElseStatement的用法示例。


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

示例1: InlineCommentAtEndOfCondition

        public void InlineCommentAtEndOfCondition()
        {
            IfElseStatement condition = new IfElseStatement();
            condition.AddChild(new CSharpTokenNode(new TextLocation(1, 1), IfElseStatement.IfKeywordRole), IfElseStatement.IfKeywordRole);
            condition.AddChild(new CSharpTokenNode(new TextLocation(1, 4), Roles.LPar), Roles.LPar);
            condition.AddChild(new IdentifierExpression("cond", new TextLocation(1, 5)), IfElseStatement.ConditionRole);
            condition.AddChild(new Comment(CommentType.MultiLine, new TextLocation(1, 9), new TextLocation(1, 14)) { Content = "a" }, Roles.Comment);
            condition.AddChild(new CSharpTokenNode(new TextLocation(1, 14), Roles.RPar), Roles.RPar);
            condition.AddChild(new ReturnStatement(), IfElseStatement.TrueRole);

            AssertOutput("if (cond/*a*/)\n$return;\n", condition);
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:12,代码来源:CSharpOutputVisitorTests.cs

示例2: Visit

			public override object Visit (If ifStatement)
			{
				var result = new IfElseStatement ();
				
				var location = LocationsBag.GetLocations (ifStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc), "if".Length), IfElseStatement.IfKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IfElseStatement.Roles.LPar);
				result.AddChild ((INode)ifStatement.Expr.Accept (this), IfElseStatement.Roles.Condition);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IfElseStatement.Roles.RPar);
				
				result.AddChild ((INode)ifStatement.TrueStatement.Accept (this), IfElseStatement.TrueEmbeddedStatementRole);
				
				if (ifStatement.FalseStatement != null) {
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[2]), "else".Length), IfElseStatement.ElseKeywordRole);
					result.AddChild ((INode)ifStatement.FalseStatement.Accept (this), IfElseStatement.FalseEmbeddedStatementRole);
				}
				
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:23,代码来源:CSharpParser.cs

示例3: Visit

			public override object Visit(If ifStatement)
			{
				var result = new IfElseStatement();
				
				var location = LocationsBag.GetLocations(ifStatement);
				
				result.AddChild(new CSharpTokenNode(Convert(ifStatement.loc), IfElseStatement.IfKeywordRole), IfElseStatement.IfKeywordRole);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
				if (ifStatement.Expr != null)
					result.AddChild((Expression)ifStatement.Expr.Accept(this), Roles.Condition);
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				
				if (ifStatement.TrueStatement != null)
					result.AddChild((Statement)ifStatement.TrueStatement.Accept(this), IfElseStatement.TrueRole);
				
				if (ifStatement.FalseStatement != null) {
					if (location != null && location.Count > 2)
						result.AddChild(new CSharpTokenNode(Convert(location [2]), IfElseStatement.ElseKeywordRole), IfElseStatement.ElseKeywordRole);
					result.AddChild((Statement)ifStatement.FalseStatement.Accept(this), IfElseStatement.FalseRole);
				}
				
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:25,代码来源:CSharpParser.cs


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