Esempio n. 1
0
        public void CastExpression_CastBoxedValue()
        {
            CastExpression <int> exp  = new CastExpression <int>();
            Func <object, int>   cast = exp.GetFunc();
            object answer             = 1.1;

            int castAnswer = cast(answer);

            Assert.AreNotEqual(1, answer);
            Assert.AreEqual(1, castAnswer);
        }
Esempio n. 2
0
        /// <summary>
        ///		Executes the expression and returns the resulting value, cast as
        ///		the specified object type.
        /// </summary>
        /// <typeparam name="T">
        ///		Object type to cast the return value as.
        /// </typeparam>
        /// <returns>
        ///		Value specified to be returned from the expression.
        /// </returns>
        public T Eval <T>()
        {
            if (!callerInitialized)
            {
                caller            = Assembly.GetCallingAssembly().Location;
                callerInitialized = true;
            }

            object answer = EvalInternal();

            CastExpression <T> exp  = new CastExpression <T>();
            Func <object, T>   cast = exp.GetFunc();

            return(cast(answer));
        }