public static Dictionary <string, object> Pack(ListInitExpression expression) { if (expression == null) { throw new ArgumentNullException("expression"); } return(new Dictionary <string, object>(3) { { Constants.EXPRESSION_TYPE_ATTRIBUTE, Constants.EXPRESSION_TYPE_LIST_INIT }, { Constants.NEW_ATTRIBUTE, AnyPacker.Pack(expression.NewExpression) }, { Constants.INITIALIZERS_ATTRIBUTE, MemberInitPacker.Pack(expression.Initializers) }, }); }
public static Dictionary <string, object> Pack(Expression expression) { if (expression == null) { throw new ArgumentNullException("expression"); } switch (expression.NodeType) { case ExpressionType.Not: case ExpressionType.NegateChecked: case ExpressionType.Negate: case ExpressionType.UnaryPlus: return(UnaryPacker.Pack((UnaryExpression)expression)); case ExpressionType.RightShift: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: case ExpressionType.Power: case ExpressionType.NotEqual: case ExpressionType.Or: case ExpressionType.OrElse: case ExpressionType.MultiplyChecked: case ExpressionType.Multiply: case ExpressionType.Modulo: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.LeftShift: case ExpressionType.GreaterThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.ExclusiveOr: case ExpressionType.Equal: case ExpressionType.Divide: case ExpressionType.Coalesce: case ExpressionType.AndAlso: case ExpressionType.And: case ExpressionType.AddChecked: case ExpressionType.Add: return(BinaryPacker.Pack((BinaryExpression)expression)); case ExpressionType.Conditional: return(ConditionPacker.Pack((ConditionalExpression)expression)); case ExpressionType.ArrayLength: return(ArrayLengthPacker.Pack((UnaryExpression)expression)); case ExpressionType.ArrayIndex: return(ArrayIndexPacker.Pack(expression)); case ExpressionType.Call: return(CallPacker.Pack((MethodCallExpression)expression)); case ExpressionType.Constant: return(ConstantPacker.Pack((ConstantExpression)expression)); case ExpressionType.Convert: case ExpressionType.ConvertChecked: return(ConvertPacker.Pack((UnaryExpression)expression)); case ExpressionType.Invoke: return(InvokePacker.Pack((InvocationExpression)expression)); case ExpressionType.Lambda: return(LambdaPacker.Pack((LambdaExpression)expression)); case ExpressionType.ListInit: return(ListInitPacker.Pack((ListInitExpression)expression)); case ExpressionType.MemberAccess: return(MemberAccessPacker.Pack((MemberExpression)expression)); case ExpressionType.MemberInit: return(MemberInitPacker.Pack((MemberInitExpression)expression)); case ExpressionType.New: return(NewPacker.Pack((NewExpression)expression)); case ExpressionType.NewArrayBounds: case ExpressionType.NewArrayInit: return(NewArrayPacker.Pack((NewArrayExpression)expression)); case ExpressionType.Parameter: return(ParameterPacker.Pack((ParameterExpression)expression)); case ExpressionType.Quote: return(QuotePacker.Pack((UnaryExpression)expression)); case ExpressionType.TypeAs: return(TypeAsPacker.Pack((UnaryExpression)expression)); case ExpressionType.TypeIs: return(TypeIsPacker.Pack((TypeBinaryExpression)expression)); default: throw new ArgumentOutOfRangeException(); } }