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


C# Expressions.UnaryExpression类代码示例

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


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

示例1: ArrayLength

 internal static ArrayLength ArrayLength(UnaryExpression expression)
 {
     return new ArrayLength()
     {
         Operand = Serialize(expression.Operand),
     }.Apply(n => n.Type = TypeRef.Serialize(expression.Type));
 }
开发者ID:takeshik,项目名称:yacq,代码行数:7,代码来源:ArrayLength.cs

示例2: VisitUnary

 protected override Expression VisitUnary(UnaryExpression node)
 {
     if (node.NodeType == ExpressionType.Not && node.Operand is MemberExpression)
     {
         return base.VisitUnary(node);
     }
     var exp = base.VisitUnary(node);
     if (node.NodeType == ExpressionType.Not)
     {
         string condition = _conditionStack.Pop();
         _conditionStack.Push("(NOT " + condition + ")");
     }
     else if (node.NodeType == ExpressionType.Convert)
     {
         if (node.Operand is ConstantExpression)
         {
             _constStack.Push((node.Operand as ConstantExpression).Value);
         }
     }
     else
     {
         throw new Exception("未支持一元操作符:" + node.NodeType.ToString());
     }
     return exp;
 }
开发者ID:dusdong,项目名称:BaseComponent,代码行数:25,代码来源:WhereExpressionVisitor.cs

示例3: VisitConvert

 private static SqlExpression VisitConvert(UnaryExpression expression)
 {
     if (expression.Operand.NodeType == ExpressionType.MemberAccess) {
         return VisitMemberAccess((MemberExpression)expression.Operand);
     }
     throw new NotImplementedException();
 }
开发者ID:arturcp,项目名称:boycott,代码行数:7,代码来源:SqlWhereVisitor.cs

示例4: VisitUnary

            protected override Expression VisitUnary(UnaryExpression node)
            {
                switch (node.NodeType)
                {
                    case ExpressionType.Not:
                        if (node.Operand is SubQueryExpression)
                        {
                            var nested = new WhereClauseVisitor(_parent, _mapping);
                            nested.Visit(node.Operand);

                            var @where = new NotWhereFragment(nested.ToWhereFragment());
                            _register.Peek()(@where);
                        }
                        else
                        {
                            var visitor = new NotVisitor(this, _mapping, _register.Peek());
                            visitor.Visit(node);
                        }

                        return null;
                }


                return base.VisitUnary(node);
            }
开发者ID:JasperFx,项目名称:marten,代码行数:25,代码来源:WhereClauseVisitor.cs

示例5: Quote

 internal static Quote Quote(UnaryExpression expression)
 {
     return new Quote()
     {
         Operand = Serialize(expression.Operand),
     }.Apply(n => n.Type = TypeRef.Serialize(expression.Type));
 }
开发者ID:takeshik,项目名称:yacq,代码行数:7,代码来源:Quote.cs

示例6: VisitUnary

        protected override Expression VisitUnary(UnaryExpression node) {
            if (node.NodeType == ExpressionType.Convert) {
                return Expression.ConvertChecked(node.Operand, node.Type);
            }

            return base.VisitUnary(node);
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:ConvertCheckedVisitor.cs

示例7: ParseUnaryNot

        static Node ParseUnaryNot(UnaryExpression e)
        {
            string suffix = e.Operand is BinaryExpression ? ")" : null;
            string prefix = e.Operand is BinaryExpression ? "!(" : "!";

            return new UnaryNode { Prefix = prefix, Operand = Parse(e.Operand), PrefixValue = GetValue(e), Suffix = suffix };
        }
开发者ID:joshrobb,项目名称:PowerAssert.Net,代码行数:7,代码来源:ExpressionParser.cs

示例8: VisitUnary

 protected override Expression VisitUnary(UnaryExpression u)
 {
     throw new NotSupportedException(
         string.Format(
             "The unary operator '{0}' is not supported",
             u.NodeType));
 }
开发者ID:sandrapatfer,项目名称:PROMPT11-02-AdvancedProgramming.vilhena,代码行数:7,代码来源:ImageQueryTranslator.cs

示例9: VisitUnary

 protected override Expression VisitUnary(UnaryExpression node)
 {
     return Expression.MakeUnary(
         node.NodeType,
         Visit(node.Operand),
         node.Type);
 }
开发者ID:fedeneo77,项目名称:Handlebars.Net,代码行数:7,代码来源:PathBinder.cs

示例10: VisitUnary

		protected override Expression VisitUnary(UnaryExpression unaryExpression)
		{
			if (unaryExpression.NodeType == ExpressionType.Not && unaryExpression.Type.GetUnwrappedNullableType() == typeof(bool))
			{
				var operand = this.Visit(unaryExpression.Operand);

				if (operand is BitBooleanExpression)
				{
					return Expression.MakeUnary(unaryExpression.NodeType, Expression.Equal(operand, Expression.Constant(true, operand.Type)), typeof(bool));
				}
			}
			else if (unaryExpression.NodeType == ExpressionType.Convert
				&& unaryExpression.Type.GetUnwrappedNullableType() == typeof(bool)
				&& unaryExpression.Operand.Type.GetUnwrappedNullableType() != typeof(bool))
			{
				var operand = this.Visit(unaryExpression.Operand);

				if (operand is BitBooleanExpression)
				{
					return Expression.MakeUnary(unaryExpression.NodeType, Expression.Equal(operand, Expression.Constant(true, operand.Type)), typeof(bool));
				}
			}

			return base.VisitUnary(unaryExpression);
		}
开发者ID:tumtumtum,项目名称:Shaolinq,代码行数:25,代码来源:SqlServerBooleanNormalizer.cs

示例11: VisitUnary

        protected override Expression VisitUnary(UnaryExpression node)
        {
            if (node.NodeType != ExpressionType.Convert && node.NodeType != ExpressionType.ConvertChecked)
            {
                return base.VisitUnary(node);
            }

            if (node.Operand.NodeType != ExpressionType.MemberAccess)
            {
                return base.VisitUnary(node);
            }

            if (!ReflectionHelper.IsNullable(node.Type))
            {
                return base.VisitUnary(node);
            }

            MemberExpression memberNode = node.Operand as MemberExpression;

            if (memberNode.Expression == null)
            {
                // Static member access cannot be rewritten
                return base.VisitUnary(node);
            }

            return this.CreateSafeMemberAccessExpression(node.Operand as MemberExpression, node.Type);
        }
开发者ID:RageRabbit,项目名称:nmemory,代码行数:27,代码来源:PropertyAccessRewriter.cs

示例12: AddQueryPart

        public void AddQueryPart(UnaryExpression leftItem, ConstantExpression rightValue, ExpressionType nodeType)
        {
            if(leftItem.Operand is MethodCallExpression)
            {
                var unaryOperation = (MethodCallExpression)leftItem.Operand;

                if(unaryOperation.Method.Name != "get_Item")
                {
                    throw new InvalidOperationException("Queries based on " + leftItem.Method.Name + " are not yet supported.");
                }

                if(unaryOperation.Arguments[0] is ConstantExpression)
                {
                    var attributeRef = ((ConstantExpression) unaryOperation.Arguments[0]).Value;
                    AddCriteriaToActiveSearchCondition(attributeRef.ToString(), rightValue.Value, GetSearchRelationType(nodeType));
                }
                else
                {
                    throw new InvalidOperationException("Only constant expressions are currently supported.");
                }

            }
            else
            {
                throw new InvalidOperationException("Queries based on " + leftItem.Method.Name + " are not yet supported.");
            }
        }
开发者ID:davidwhitney,项目名称:QuantivContrib,代码行数:27,代码来源:QuantivEntityQueryBuilder.cs

示例13: VisitUnary

 protected override Expression VisitUnary(UnaryExpression u)
 {
     if (u.NodeType == ExpressionType.Quote)
     {
         return base.Visit(u.Operand);
     }
     return base.VisitUnary(u);
 }
开发者ID:akselsson,项目名称:LinqToEPiServer,代码行数:8,代码来源:QuoteStripper.cs

示例14: Unbox

 internal static Unbox Unbox(UnaryExpression expression)
 {
     return new Unbox()
     {
         Operand = Serialize(expression.Operand),
         Type = TypeRef.Serialize(expression.Type),
     };
 }
开发者ID:takeshik,项目名称:yacq,代码行数:8,代码来源:Unbox.cs

示例15: VisitUnary

        protected override Expression VisitUnary(UnaryExpression u)
        {
            u = (UnaryExpression)base.VisitUnary(u);
            if (u.NodeType != ExpressionType.Not)
                return u;

            return Invert(u.Operand, u);
        }
开发者ID:ashmind,项目名称:expressive,代码行数:8,代码来源:NotImprovementVisitor.cs


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