public void Deserialize_UseCorrectTypes_WhenParametersDefined()
        {
            Serializer s = new Serializer(typeof(CtorMock2));
            ObjectExpression expr = new ObjectExpression();
            expr.ResultType = typeof(CtorMock2);
            NumericExpression IDExpr = new NumericExpression("10");
            ObjectExpression objExpr = new ObjectExpression();
            objExpr.ConstructorArguments.Add(new ValueExpression("name"));
            expr.ConstructorArguments.Add(IDExpr);
            expr.ConstructorArguments.Add(objExpr);
            Type[] definedTypes = new Type[] { typeof(int), typeof(MyObject2) };
            CtorArgTypeResolver resolver = new CtorArgTypeResolver(expr, s.Config, definedTypes);
            Type[] argTypes = resolver.ResolveTypes();
            CollectionAssert.AreElementsEqual(new Type[] { typeof(long), typeof(MyObject2) }, argTypes);

            // Try to construct
            IDExpr.ResultType = typeof(long);
            objExpr.ResultType = typeof(MyObject2);
            Evaluator eval = new Evaluator(s.Config);
            object result = eval.Evaluate(expr);            
        }
Esempio n. 2
0
 protected virtual void Evaluate(Expression expression, object target)
 {
     Evaluator eval = new Evaluator(this.Config);
     eval.Evaluate(expression, target);
 }
Esempio n. 3
0
 protected virtual object Evaluate(Expression expression)
 {
     Evaluator eval = new Evaluator(this.Config);
     return eval.Evaluate(expression);
 }