本文整理汇总了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();
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}