0
我有一個覆蓋Unary Visitor似乎工作正常,但我需要從節點獲取操作數的值。自定義表達式樹訪問者 - 如何獲取UnaryExpression節點的值?
如果它是一個常量表達式,這是很容易實現:
var value = ((ConstantExpression) node.Operand).Value;
的問題是如何實現這一目標,如果節點是值類型像一個int MemberExpression:
protected override Expression VisitUnary(UnaryExpression node)
{
//get the value stored in the node.Operand
}