本文整理汇总了C#中System.Linq.Expressions.Expression.CastExpr方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.CastExpr方法的具体用法?C# Expression.CastExpr怎么用?C# Expression.CastExpr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.CastExpr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CastFromBinding
protected MethodCallExpression CastFromBinding(Expression expr)
{
var me = expr.CastExpr<MethodCallExpression> (ExpressionType.Call);
return me != null && me.Method.IsLiftMethod () ? me : null;
}
示例2: FunctionBody
protected void FunctionBody(Expression expr)
{
var node = expr.CastExpr<MethodCallExpression> (ExpressionType.Call);
CodeOut ("return {0};", Expr (RemoveAggregates (
node != null && node.Method.IsEvaluate (_linqType) ? ParseLinqExpression (node.Arguments [0]) : expr)));
}
示例3: Return
protected void Return(Expression expr)
{
expr = RemoveAggregates (expr);
var ne = expr.CastExpr<NewExpression> (ExpressionType.New);
if (ne == null)
{
var mie = expr.CastExpr<MemberInitExpression> (ExpressionType.MemberInit);
if (mie == null)
throw new ParseException ("Unsupported expression: " + expr);
foreach (MemberAssignment assign in mie.Bindings)
CodeOut ("{0} = {1};", assign.Member.Name, Expr (assign.Expression));
}
else
{
for (int i = 0; i < ne.Members.Count; i++)
{
var prop = (PropertyInfo)ne.Members[i];
if (!prop.Name.StartsWith ("<>"))
CodeOut ("{0} = {1};", prop.Name, Expr (ne.Arguments[i]));
}
}
}
示例4: ConditionalReturn
protected void ConditionalReturn(Expression expr, Action<Expression> returnAction)
{
var ce = expr.CastExpr<ConditionalExpression> (ExpressionType.Conditional);
if (ce == null)
returnAction (expr);
else
{
CodeOut ("if ({0})", Expr (ce.Test));
CodeOut ("{");
_tabLevel++;
returnAction (ce.IfTrue);
_tabLevel--;
CodeOut ("}");
CodeOut ("else");
CodeOut ("{");
_tabLevel++;
ConditionalReturn (ce.IfFalse, returnAction);
_tabLevel--;
CodeOut ("}");
}
}