public void CallMethod_By_Delegate()
        {
            var getAreaInvoker = MethodExtensions.DelegateForCallMethod(widgetType, "GetArea");

            foreach (var widget in _widgets)
            {
                var area = (double)getAreaInvoker.Invoke(widget);
                Assert.AreEqual(widget.GetArea(), area);
            }
        }
Exemple #2
0
        /// <summary>
        /// 특정 수형의 특정 메소드를 호출할 수 있는 델리게이트를 제공합니다.
        /// </summary>
        /// <seealso cref="MethodExtensions.DelegateForCallMethod(System.Type,string,System.Type[])"/>
        public static MethodInvoker GetMethodInvoker(this Type instanceType, string methodName, params Type[] parameterTypes)
        {
            instanceType.ShouldNotBeNull("instanceType");
            methodName.ShouldNotBeWhiteSpace("methodName");

            if (IsDebugEnabled)
            {
                log.Debug("Get CallMethod for Delegate... instanceType=[{0}], methodName=[{1}], parameterTypes=[{2}]",
                          instanceType, methodName, parameterTypes.CollectionToString());
            }

            return(MethodExtensions.DelegateForCallMethod(instanceType, methodName, parameterTypes));
        }