/// <summary>
 /// Converts an expression to an object by first Evaluating the expression as its converted type and
 /// then converting that result using the specified type converter.
 /// </summary>
 /// <param name="expression">the expression to convert</param>
 /// <param name="deserializer">deserializer instance</param>
 /// <param name="converter">the converter to use to convert the object</param>
 /// <returns>an object created from the expression</returns>
 public object Evaluate(Expression expression, IDeserializerHandler deserializer, IJsonTypeConverter converter)
 {
     Type sourceType = expression.ResultType;
     Type destType = converter.GetSerializedType(sourceType);
     expression.ResultType = destType;
     object tempResult = deserializer.Evaluate(expression);
     object result = converter.ConvertTo(tempResult, sourceType, Context);
     expression.OnObjectConstructed(result);
     if (result is IDeserializationCallback)
     {
         ((IDeserializationCallback)result).OnAfterDeserialization();
     }
     return result;
 }
 /// <summary>
 /// Converts an expression to an object by first Evaluating the expression as its converted type and
 /// then converting that result using the specified type converter.
 /// </summary>
 /// <param name="expression">the expression to convert</param>
 /// <param name="deserializer">deserializer instance</param>
 /// <param name="converter">the converter to use to convert the object</param>
 /// <returns>an object created from the expression</returns>
 public object Evaluate(Expression expression, IDeserializerHandler deserializer, IJsonTypeConverter converter)
 {
     Type sourceType = expression.ResultType;
     Type destType = converter.GetSerializedType(sourceType);
     expression.ResultType = destType;
     object tempResult = deserializer.Evaluate(expression);
     //TODO: Cast for now to avoid breaking compatibility
     object result = converter.ConvertTo(tempResult, sourceType, (SerializationContext) Config);
     expression.OnObjectConstructed(result);
     if (result is IDeserializationCallback)
     {
         ((IDeserializationCallback)result).OnAfterDeserialization();
     }
     return result;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts an expression to an object by first Evaluating the expression as its converted type and
        /// then converting that result using the specified type converter.
        /// </summary>
        /// <param name="expression">the expression to convert</param>
        /// <param name="deserializer">deserializer instance</param>
        /// <param name="converter">the converter to use to convert the object</param>
        /// <returns>an object created from the expression</returns>
        public object Evaluate(Expression expression, IDeserializerHandler deserializer, IJsonTypeConverter converter)
        {
            Type sourceType = expression.ResultType;
            Type destType   = converter.GetSerializedType(sourceType);

            expression.ResultType = destType;
            object tempResult = deserializer.Evaluate(expression);
            object result     = converter.ConvertTo(tempResult, sourceType, Context);

            expression.OnObjectConstructed(result);
            if (result is IDeserializationCallback)
            {
                ((IDeserializationCallback)result).OnAfterDeserialization();
            }
            return(result);
        }
        /// <summary>
        /// Converts an expression to an object by first Evaluating the expression as its converted type and
        /// then converting that result using the specified type converter.
        /// </summary>
        /// <param name="expression">the expression to convert</param>
        /// <param name="deserializer">deserializer instance</param>
        /// <param name="converter">the converter to use to convert the object</param>
        /// <returns>an object created from the expression</returns>
        public object Evaluate(Expression expression, IDeserializerHandler deserializer, IJsonTypeConverter converter)
        {
            Type sourceType = expression.ResultType;
            Type destType   = converter.GetSerializedType(sourceType);

            expression.ResultType = destType;
            object tempResult = deserializer.Evaluate(expression);
            //TODO: Cast for now to avoid breaking compatibility
            object result = converter.ConvertTo(tempResult, sourceType, (SerializerSettings)Settings);

            expression.OnObjectConstructed(result);
            if (result is IDeserializationCallback)
            {
                ((IDeserializationCallback)result).OnAfterDeserialization();
            }
            return(result);
        }