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


C# ConditionalExpression类代码示例

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


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

示例1: VisitConditionalExpression

		public override void VisitConditionalExpression(ConditionalExpression conditionalExpression)
		{
            var token = CreateConditionalBlock(conditionalExpression.Condition.GetText());
            _tokenList.Add(token);

            VisitChildren(token.FalseStatements, conditionalExpression.FalseExpression);
            VisitChildren(token.TrueStatements, conditionalExpression.TrueExpression);		
		}        
开发者ID:JoeHosman,项目名称:sharpDox,代码行数:8,代码来源:MethodVisitor.cs

示例2: UpdateConditional

 protected ConditionalExpression UpdateConditional(ConditionalExpression c, Expression test, Expression ifTrue, Expression ifFalse)
 {
     if (test != c.Test || ifTrue != c.IfTrue || ifFalse != c.IfFalse)
     {
         return Expression.Condition(test, ifTrue, ifFalse);
     }
     return c;
 }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:8,代码来源:ExpressionVisitor.cs

示例3: VisitConditionalExpression

			public override void VisitConditionalExpression (ConditionalExpression conditionalExpression)
			{
				base.VisitConditionalExpression (conditionalExpression);

				if (!conditionalExpression.TrueExpression.Match (conditionalExpression.FalseExpression).Success)
					return;
				var action = new CodeAction (ctx.TranslateString ("Replace '?:' with branch"),
					script => script.Replace (conditionalExpression, conditionalExpression.TrueExpression.Clone ()));
				AddIssue (conditionalExpression, 
					ctx.TranslateString ("'?:' expression has identical true and false branches"), new [] { action });
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:11,代码来源:IdenticalConditionalBranchIssue.cs

示例4: VisitConditionalExpression

			public override void VisitConditionalExpression(ConditionalExpression conditionalExpression)
			{
				Match m = pattern.Match(conditionalExpression);
				if (m.Success) {
					var a = m.Get<Expression>("a").Single();
					var other = m.Get<Expression>("other").Single();
					AddIssue(conditionalExpression, ctx.TranslateString("Convert to '??' expression"), script => {
						var expr = new BinaryOperatorExpression (a.Clone (), BinaryOperatorType.NullCoalescing, other.Clone ());
						script.Replace (conditionalExpression, expr);
					});
				}
				base.VisitConditionalExpression (conditionalExpression);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:13,代码来源:ConditionalToNullCoalescingIssue.cs

示例5: GetExpressions

		public Tuple<Expression, Expression> GetExpressions (ConditionalExpression cond)
		{
			var condition = cond.Condition as BinaryOperatorExpression;
			var compareNode = condition.Left is NullReferenceExpression ? condition.Right : condition.Left;

			if (compareNode.IsMatch (cond.TrueExpression)) {
				// a != null ? a : other
				return new Tuple<Expression, Expression> (cond.TrueExpression, cond.FalseExpression);
			}

			// a == null ? other : a
			return new Tuple<Expression, Expression> (cond.FalseExpression, cond.TrueExpression);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:ConditionalToNullCoalescingInspector.cs

示例6: IsCandidate

		public bool IsCandidate (ConditionalExpression node)
		{
			var condition = node.Condition as BinaryOperatorExpression;
			var compareNode = condition.Left is NullReferenceExpression ? condition.Right : condition.Left;
			
			
			if (compareNode.IsMatch (node.TrueExpression)) {
				// a == null ? a : other
				if (condition.Operator == BinaryOperatorType.Equality) 
					return false;
				// a != null ? a : other
				return compareNode.IsMatch (node.TrueExpression);
			} else {
				// a == null ? other : a
				if (condition.Operator == BinaryOperatorType.Equality)
					return compareNode.IsMatch (node.FalseExpression);
				// a != null ? other : a
				return false;
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:20,代码来源:ConditionalToNullCoalescingInspector.cs

示例7: VisitConditionalExpression

			public override void VisitConditionalExpression (ConditionalExpression conditionalExpression)
			{
				var resolveResult = ctx.Resolve (conditionalExpression.Condition);
				if (resolveResult.ConstantValue is bool) {
					var condition = (bool)resolveResult.ConstantValue;
					Expression resultExpr, unreachableExpr;
					if (condition) {
						resultExpr = conditionalExpression.TrueExpression;
						unreachableExpr = conditionalExpression.FalseExpression;
					} else {
						resultExpr = conditionalExpression.FalseExpression;
						unreachableExpr = conditionalExpression.TrueExpression;
					}
					unreachableNodes.Add (unreachableExpr);

					AddIssue (unreachableExpr, ctx.TranslateString ("Remove unreachable code"),
						script => script.Replace (conditionalExpression, resultExpr.Clone ()));
				}
				base.VisitConditionalExpression (conditionalExpression);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:20,代码来源:UnreachableCodeIssue.cs

示例8: Walk

 // ConditionalExpression
 public override bool Walk(ConditionalExpression node) { return false; }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:2,代码来源:PythonWalker.Generated.cs

示例9: Walk

 // ConditionalExpression
 protected internal virtual bool Walk(ConditionalExpression node) { return true; }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:2,代码来源:Walker.Generated.cs

示例10: PostWalk

 protected internal virtual void PostWalk(ConditionalExpression node) { }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:1,代码来源:Walker.Generated.cs

示例11: Exit

 public override void Exit(ConditionalExpression node)
 {
     level--;
 }
开发者ID:buunguyen,项目名称:bike,代码行数:4,代码来源:PrintNodeWalker.cs

示例12: Enter

 public override bool Enter(ConditionalExpression node)
 {
     Print("ConditionalExpression");
     level++;
     return true;
 }
开发者ID:buunguyen,项目名称:bike,代码行数:6,代码来源:PrintNodeWalker.cs

示例13: actionPerformed

 /**
  * Call back method that must be called as soon as the given <code>
  * ConditionalExpression</code> object has been traversed.
  *
  * @param pConditionalExpression  The <code>ConditionalExpression</code>
  *                                object that has just been traversed.
  */
 public void actionPerformed(
      
     ConditionalExpression pConditionalExpression)
 {
     // Nothing to do.
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:13,代码来源:TraverseActionAdapter.cs

示例14: Walk

 public override bool Walk(ConditionalExpression node)
 {
     node.Parent = _currentScope;
     return base.Walk(node);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:5,代码来源:PythonNameBinder.cs

示例15: VisitConditionalExpression

 public void VisitConditionalExpression(ConditionalExpression condExpr)
 {
     condExpr.Condition.AcceptWalker(this);
     condExpr.TrueExpression.AcceptWalker(this);
     condExpr.FalseExpression.AcceptWalker(this);
 }
开发者ID:hazama-yuinyan,项目名称:Expresso,代码行数:6,代码来源:ExpressoNameBinder.cs


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