Exemplo n.º 1
0
        public void CallStaticMethod()
        {
            IEnumerable values = Enumerable.Range(1, 4);
            var         b      = Enumerable.Cast <int>(values);

            Assert.IsTrue(b is IEnumerable <int>);
            //same call dynamic :)
            var o = TypeUtils.CallStaticGenericMethod(typeof(Enumerable), "Cast", typeof(int), values);

            Assert.IsTrue(o is IEnumerable <int>);
        }
Exemplo n.º 2
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 });
        }