Beispiel #1
0
        public void DelegateUtil_ConvertTo_InstanceComplitable()  //实例的可兼容方法,
        {
            var  method   = this.GetType().GetMethod("Multiply_InstanceComplitable");
            Call objCall1 = DelegateUtil.ConvertTo <Call>(method, new DelegateUtilTests());

            Assert.AreEqual(10, objCall1(2, 5));
        }
Beispiel #2
0
        public void DelegateUtil_ConvertTo_StaticComplitable()   //静态方法,参数可兼容
        {
            var  method   = this.GetType().GetMethod("Multiply_StaticComplitable", BindingFlags.Static | BindingFlags.Public);
            Call objCall1 = DelegateUtil.ConvertTo <Call>(method, null);

            Assert.IsNotNull(objCall1);
            Assert.AreEqual(10, objCall1(2, 5));
        }
Beispiel #3
0
        public void DelegateUtil_ConvertTo_Multiply_InstanceFullfit() //实例方法,参数完全一致;
        {
            var  method   = this.GetType().GetMethod("Multiply_InstanceFullfit", BindingFlags.Instance | BindingFlags.Public);
            Call objCall1 = DelegateUtil.ConvertTo <Call>(method, new DelegateUtilTests());

            Assert.IsNotNull(objCall1);
            Assert.AreEqual(10, objCall1(2, 5));
        }
Beispiel #4
0
        public void DelegateUtil_ConvertTo_Static_FullComplicatable() //静态方法,参数和返回类型完全一致;
        {
            Call objCall;                                             //第二步:声明委托变量

            objCall = Multiply_StaticFullfit;
            var  method   = this.GetType().GetMethod("Multiply_StaticFullfit");
            Call objCall1 = DelegateUtil.ConvertTo <Call>(method, null);

            Assert.IsNotNull(objCall);

            Assert.AreEqual(10, objCall1(2, 5));
        }