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


C# IExpression.Equals方法代码示例

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


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

示例1: And

		/// <summary>Optimizations: f&&X-&gt;f, t&&X-&gt;X, X&&X-&gt;X, X&&!X-&gt;f</summary>
		public virtual IExpression And(IExpression left, IExpression right)
		{
			if (left.Equals(BoolConstExpression.False) || right.Equals(BoolConstExpression.False
				))
			{
				return BoolConstExpression.False;
			}
			if (left.Equals(BoolConstExpression.True))
			{
				return right;
			}
			if (right.Equals(BoolConstExpression.True))
			{
				return left;
			}
			if (left.Equals(right))
			{
				return left;
			}
			if (Negatives(left, right))
			{
				return BoolConstExpression.False;
			}
			return new AndExpression(left, right);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:26,代码来源:ExpressionBuilder.cs

示例2: Not

		/// <summary>Optimizations: !(Bool)-&gt;(!Bool), !!X-&gt;X, !(X==Bool)-&gt;(X==!Bool)
		/// 	</summary>
		public virtual IExpression Not(IExpression expr)
		{
			if (expr.Equals(BoolConstExpression.True))
			{
				return BoolConstExpression.False;
			}
			if (expr.Equals(BoolConstExpression.False))
			{
				return BoolConstExpression.True;
			}
			if (expr is NotExpression)
			{
				return ((NotExpression)expr).Expr();
			}
			if (expr is ComparisonExpression)
			{
				ComparisonExpression cmpExpr = (ComparisonExpression)expr;
				if (cmpExpr.Right() is ConstValue)
				{
					ConstValue rightConst = (ConstValue)cmpExpr.Right();
					if (rightConst.Value() is bool)
					{
						bool boolVal = (bool)rightConst.Value();
						// new Boolean() instead of Boolean.valueOf() for .NET conversion
						return new ComparisonExpression(cmpExpr.Left(), new ConstValue(!boolVal), cmpExpr
							.Op());
					}
				}
			}
			return new NotExpression(expr);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:33,代码来源:ExpressionBuilder.cs

示例3: CheckBoolean

		private IExpression CheckBoolean(IExpression cmp, IExpression trueExpr, IExpression
			 falseExpr)
		{
			if (cmp is BoolConstExpression)
			{
				return null;
			}
			if (trueExpr is BoolConstExpression)
			{
				bool leftNegative = trueExpr.Equals(BoolConstExpression.False);
				if (!leftNegative)
				{
					return Or(cmp, falseExpr);
				}
				else
				{
					return And(Not(cmp), falseExpr);
				}
			}
			if (falseExpr is BoolConstExpression)
			{
				bool rightNegative = falseExpr.Equals(BoolConstExpression.False);
				if (!rightNegative)
				{
					return And(cmp, trueExpr);
				}
				else
				{
					return Or(Not(cmp), falseExpr);
				}
			}
			if (cmp is NotExpression)
			{
				cmp = ((NotExpression)cmp).Expr();
				IExpression swap = trueExpr;
				trueExpr = falseExpr;
				falseExpr = swap;
			}
			if (trueExpr is OrExpression)
			{
				OrExpression orExpr = (OrExpression)trueExpr;
				IExpression orLeft = orExpr.Left();
				IExpression orRight = orExpr.Right();
				if (falseExpr.Equals(orRight))
				{
					IExpression swap = orRight;
					orRight = orLeft;
					orLeft = swap;
				}
				if (falseExpr.Equals(orLeft))
				{
					return Or(orLeft, And(cmp, orRight));
				}
			}
			if (falseExpr is AndExpression)
			{
				AndExpression andExpr = (AndExpression)falseExpr;
				IExpression andLeft = andExpr.Left();
				IExpression andRight = andExpr.Right();
				if (trueExpr.Equals(andRight))
				{
					IExpression swap = andRight;
					andRight = andLeft;
					andLeft = swap;
				}
				if (trueExpr.Equals(andLeft))
				{
					return And(andLeft, Or(cmp, andRight));
				}
			}
			return null;
		}
开发者ID:erdincay,项目名称:db4o,代码行数:72,代码来源:ExpressionBuilder.cs

示例4: HasVar

        /// <summary>
        /// Checks the <paramref name="expression"/> parameter has <paramref name="arg"/>.
        /// </summary>
        /// <param name="expression">A expression that is checked.</param>
        /// <param name="arg">A variable that can be contained in the expression.</param>
        /// <returns>true if <paramref name="expression"/> has <paramref name="arg"/>; otherwise, false.</returns>
        public static bool HasVar(IExpression expression, Variable arg)
        {
            var bin = expression as BinaryExpression;
            if (bin != null)
                return HasVar(bin.Left, arg) || HasVar(bin.Right, arg);

            var un = expression as UnaryExpression;
            if (un != null)
                return HasVar(un.Argument, arg);

            var paramExp = expression as DifferentParametersExpression;
            if (paramExp != null)
                return paramExp.Arguments.Any(e => HasVar(e, arg));

            return expression is Variable && expression.Equals(arg);
        }
开发者ID:smwentum,项目名称:xFunc,代码行数:22,代码来源:Parser.cs


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