Example #1
0
        public virtual void AddValues(IEnumerable values)
        {
            Type t             = (this as IVariable).ValueType;
            var  genericValues = TypeUtils.CallStaticGenericMethod(typeof(Enumerable), "Cast", t, values);

            //values.Cast<>()
            //var genericValue = TypeUtils.CallGenericMethod(typeof (Enumerable), "Cast", t, values, null);

            TypeUtils.CallGenericMethod(GetType(), "AddValues", t, this,
                                        new[] { genericValues });
        }
Example #2
0
        public void CallGenericMethodUsingDynamicType()
        {
            int value = (int)TypeUtils.CallGenericMethod(GetType(), "ReturnValue", typeof(int), this, 8);

            Assert.AreEqual(8, value);

            DateTime t = (DateTime)TypeUtils.CallGenericMethod(GetType(), "ReturnValue", typeof(DateTime), this, new DateTime(2000, 1, 1));

            Assert.AreEqual(new DateTime(2000, 1, 1), t);

            TypeUtils.CallGenericMethod(GetType(), "VoidMethod", typeof(int), this, 2);
        }