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


C# UnaryExpression.ToString方法代码示例

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


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

示例1: GetCode

        private string GetCode(UnaryExpression e)
        {
            if (e.NodeType == ExpressionType.Convert)
            {
                return $"({e.Type}) {e.Operand}";
            }

            return e.ToString();
        }
开发者ID:ru-sh,项目名称:dnxt,代码行数:9,代码来源:CsMappingGenerator.cs

示例2: VisitUnary

        /// <summary>
        /// Process the not operator.
        /// </summary>
        /// <param name="expression">The expression to visit.</param>
        /// <returns>The visited expression.</returns>
        protected override Expression VisitUnary(UnaryExpression expression)
        {
            if (expression != null)
            {
                switch (expression.NodeType)
                {
                    case ExpressionType.Not:
                        this.filter.Append(" not(");
                        this.Visit(expression.Operand);
                        this.filter.Append(")");

                        this.MarkVisited();
                        break;
                    case ExpressionType.Quote:
                        this.Visit(StripUnaryOperator(expression));
                        this.MarkVisited();
                        break;
                    case ExpressionType.Convert:
                        // Ignore conversion requests if the conversion will
                        // happen implicitly on the server anyway
                        if (IsConversionImplicit(expression, expression.Operand.Type, expression.Type))
                        {
                            this.Visit(StripUnaryOperator(expression));
                            this.MarkVisited();
                            break;
                        }
                        // Otherwise the conversion isn't supported
                        goto default;
                    default:
                        throw new NotSupportedException(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                Resources.FilterBuildingExpressionVisitor_VisitOperator_Unsupported,
                                expression.NodeType,
                                expression.ToString()));
                }
            }
            return expression;
        }
开发者ID:xqiu,项目名称:azure-mobile-services,代码行数:44,代码来源:FilterBuildingExpressionVisitor.cs

示例3: VisitUnaryExpression

		protected HqlTreeNode VisitUnaryExpression(UnaryExpression expression)
		{
			switch (expression.NodeType)
			{
				case ExpressionType.Not:
					return _hqlTreeBuilder.BooleanNot(VisitExpression(expression.Operand).AsBooleanExpression());
				case ExpressionType.Convert:
				case ExpressionType.ConvertChecked:
				{
					if (expression.Operand.Type.IsPrimitive && expression.Type.IsPrimitive)
						return _hqlTreeBuilder.Cast(VisitExpression(expression.Operand).AsExpression(), expression.Type);

					return VisitExpression(expression.Operand);
				}
			}

			throw new NotSupportedException(expression.ToString());
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:18,代码来源:HqlGeneratorExpressionTreeVisitor.cs

示例4: VisitUnaryExpression

		protected HqlTreeNode VisitUnaryExpression(UnaryExpression expression)
		{
			switch (expression.NodeType)
			{
				case ExpressionType.Not:
					return _hqlTreeBuilder.BooleanNot(VisitExpression(expression.Operand).AsBooleanExpression());
				case ExpressionType.Convert:
				case ExpressionType.ConvertChecked:
				case ExpressionType.TypeAs:
					if ((expression.Operand.Type.IsPrimitive || expression.Operand.Type == typeof(Decimal)) &&
						(expression.Type.IsPrimitive || expression.Type == typeof(Decimal)))
					{
						return _hqlTreeBuilder.Cast(VisitExpression(expression.Operand).AsExpression(), expression.Type);
					}

					return VisitExpression(expression.Operand);
			}

			throw new NotSupportedException(expression.ToString());
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:20,代码来源:HqlGeneratorExpressionTreeVisitor.cs

示例5: TranslateUnary

        private string TranslateUnary(UnaryExpression expression)
        {
            string sql = Translate(expression.Operand);

            switch (expression.NodeType)
            {
                case ExpressionType.Negate:
                case ExpressionType.NegateChecked:
                    return $"(-{sql})";

                case ExpressionType.UnaryPlus:
                case ExpressionType.Unbox:
                case ExpressionType.Convert:
                case ExpressionType.ConvertChecked:
                case ExpressionType.Quote:
                    return sql;

                case ExpressionType.Not:
                    return $"(NOT {sql})";
            }

            throw new SqlExpressionTranslatorException(expression.ToString());
        }
开发者ID:carlosga,项目名称:DB,代码行数:23,代码来源:SqlExpressionTranslator.cs

示例6: VisitUnary

            /// <summary>Visits a unary expression while initializing a non-entity type structure.</summary>
            /// <param name="u">Expression to visit.</param>
            /// <returns>The visited expression.</returns>
            internal override Expression VisitUnary(UnaryExpression u)
            {
                Debug.Assert(u != null, "u != null");

                if (!ResourceBinder.PatternRules.MatchConvertToAssignable(u))
                {
                    if (ClientType.CheckElementTypeIsEntity(u.Operand.Type))
                    {
                        throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, u.ToString()));
                    }
                }
                
                return base.VisitUnary(u);
            }
开发者ID:JianwenSun,项目名称:cc,代码行数:17,代码来源:ProjectionAnalyzer.cs

示例7: VisitUnary

            internal override Expression VisitUnary(UnaryExpression u)
            {
                Debug.Assert(u != null, "u != null");

                if (!ResourceBinder.PatternRules.MatchConvertToAssignable(u))
                {
                    if (CommonUtil.IsClientType(u.Operand.Type))
                    {
                        throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.ALinqExpressionNotSupportedInProjection, this.type, u.ToString()));
                    }
                }

                return base.VisitUnary(u);
            }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:14,代码来源:ProjectionAnalyzer.cs

示例8: VisitUnaryExpression

        protected HqlTreeNode VisitUnaryExpression(UnaryExpression expression)
        {
            switch (expression.NodeType)
            {
                case ExpressionType.Not:
                    return _hqlTreeBuilder.BooleanNot(VisitExpression(expression.Operand).AsBooleanExpression());
                case ExpressionType.Convert:
                    return VisitExpression(expression.Operand);
            }

            throw new NotSupportedException(expression.ToString());
        }
开发者ID:briandonahue,项目名称:nhibernate,代码行数:12,代码来源:HqlGeneratorExpressionTreeVisitor.cs

示例9: VisitUnary

 internal override Expression VisitUnary(UnaryExpression u)
 {
     if (!ResourceBinder.PatternRules.MatchConvertToAssignable(u))
     {
         if ((u.NodeType == ExpressionType.TypeAs) && this.leafExpressionIsMemberAccess)
         {
             return base.VisitUnary(u);
         }
         if (ClientTypeUtil.TypeOrElementTypeIsEntity(u.Operand.Type))
         {
             throw new NotSupportedException(System.Data.Services.Client.Strings.ALinq_ExpressionNotSupportedInProjection(this.type, u.ToString()));
         }
     }
     return base.VisitUnary(u);
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:ProjectionAnalyzer.cs

示例10: VisitUnary

            /// <summary>Visits a unary expression while initializing a non-entity type structure.</summary>
            /// <param name="u">Expression to visit.</param>
            /// <returns>The visited expression.</returns>
            internal override Expression VisitUnary(UnaryExpression u)
            {
                Debug.Assert(u != null, "u != null");

                if (!ResourceBinder.PatternRules.MatchConvertToAssignable(u))
                {
                    // In V3 while we support TypeAs conversions, we only support TypeAs before a MemberAccess and not TypeAs as the last operation
                    // i.e. we support "Manager = (p as Employee).Manager" (see VisitMemberAccess for detail), but we dont support "Manager = (p as Manager)"
                    // Note that the server also doesn't support a property path which ends with a type identifier.
                    if (u.NodeType == ExpressionType.TypeAs && this.leafExpressionIsMemberAccess)
                    {
                        return base.VisitUnary(u);
                    }

                    if (ClientTypeUtil.TypeOrElementTypeIsEntity(u.Operand.Type))
                    {
                        throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, u.ToString()));
                    }
                }
                
                return base.VisitUnary(u);
            }
开发者ID:larsenjo,项目名称:odata.net,代码行数:25,代码来源:ProjectionAnalyzer.cs

示例11: VisitUnary

 /// <summary>
 /// Process the not operator.
 /// </summary>
 /// <param name="expression">
 /// The expression to visit.
 /// </param>
 /// <returns>
 /// The visited expression.
 /// </returns>
 private Expression VisitUnary(UnaryExpression expression)
 {
     if (expression != null)
     {
         switch (expression.NodeType)
         {
             case ExpressionType.Not:
                 this.Visit(expression.Operand);
                 this.filterExpression.Push(new UnaryOperatorNode(UnaryOperatorKind.Not, this.filterExpression.Pop()));
                 break;
             case ExpressionType.Quote:
                 this.Visit(StripUnaryOperator(expression));
                 break;
             case ExpressionType.Convert:
                 // Ignore conversion requests if the conversion will
                 // happen implicitly on the server anyway
                 if (IsConversionImplicit(expression, expression.Operand.Type, expression.Type))
                 {
                     this.Visit(StripUnaryOperator(expression));
                     break;
                 }
                 // Otherwise the conversion isn't supported
                 goto default;
             default:
                 throw new NotSupportedException(
                     string.Format(
                         CultureInfo.InvariantCulture,
                         "The operator '{0}' is not supported in the 'Where' Mobile Services query expression '{1}'.",
                         expression.NodeType,
                         expression.ToString()));
         }
     }
     return expression;
 }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:43,代码来源:FilterBuildingExpressionVisitor.cs

示例12: VisitUnary

 protected override Expression VisitUnary(UnaryExpression node)
 {
     Visit(node.Operand);
     if (node.NodeType == ExpressionType.Not)
     {
         _expression.Negated = !_expression.Negated;
     }
     else
     {
         throw new NotSupportedException(node.ToString());
     }
     return node;
 }
开发者ID:alex-fomin,项目名称:BLogic,代码行数:13,代码来源:ExpressionTranslator.cs


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