本文整理匯總了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 ("}");
}
}