コード例 #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));
        }
コード例 #2
0
        /// <summary>
        /// Deserializes JSON into an expression.
        /// </summary>
        /// <param name="json">The JSON to deserialize.</param>
        /// <returns>The deserialized expression.</returns>
        private Expression DeserializeExpression(JToken json)
        {
            if (json == null)
            {
                return(null);
            }
            else if (json.Type == JTokenType.Null)
            {
                return(null);
            }

            var jsonText = GetJsonString(json);

            if (_expressionSerializer != null)
            {
                var slim = DeserializeExpressionSlim(jsonText);
                return(_expressionSerializer.Reduce(slim));
            }
            else
            {
                return(_deserializeExpression(jsonText));
            }
        }