• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Expressions.UnaryExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: IsFalse

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


示例17: PreDecrementAssign

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


示例18: NegateChecked

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


示例19: GetColumnName

        //string GetColumnName(LambdaExpression member)
        //{
        //    var mbody = member.Body as MemberExpression;
        //    if (mbody != null) return GetColumnName(mbody);
        //    var ubody = member.Body as UnaryExpression;
        //    if (ubody == null) throw new NotSupportedException("Only members and unary expressions are supported");
        //    return GetColumnName(ubody);
        //}

        private string GetColumnName(UnaryExpression member)
        {
            var mbody = member.Operand as MemberExpression;
            if (mbody != null) return GetColumnName(mbody);
            var ubody = member.Operand as UnaryExpression;
            if (ubody != null) return GetColumnName(ubody);
            throw new NotSupportedException("Only members and unary expressions are supported");
        }
开发者ID:sapiens,项目名称:SqlFu,代码行数:17,代码来源:ExpressionSqlGenerator.cs


示例20: OnesComplement

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compiler.LambdaCompiler类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.TypeBinaryExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap