示例#1
0
        private static Expression Roundtrip(Expression expr, IExpressionSerializer serializer)
        {
            var slim             = serializer.Lift(expr);
            var bonsai           = serializer.Serialize(slim);
            var roundtrippedSlim = serializer.Deserialize(bonsai);

            return(serializer.Reduce(roundtrippedSlim));
        }
 /// <summary>
 /// Serializes an expression into JSON.
 /// </summary>
 /// <param name="serializer">The JSON serializer to use.</param>
 /// <param name="expression">The expression to serialize.</param>
 /// <returns>The serialized expression.</returns>
 private JToken SerializeExpression(JsonSerializer serializer, Expression expression)
 {
     if (_expressionSerializer != null)
     {
         var slim = _expressionSerializer.Lift(expression);
         return(SerializeExpressionSlim(serializer, slim));
     }
     else
     {
         return(Parse(serializer, _serializeExpression(expression)));
     }
 }