當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。